Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsCalculationsViewTest.cs =================================================================== diff -u -r005490b7ce22d654f4d1e5f691ffa93714545d21 -rd8deffdf2d40b56a90ed729a1c3e9892cfbea7e0 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsCalculationsViewTest.cs (.../MacroStabilityInwardsCalculationsViewTest.cs) (revision 005490b7ce22d654f4d1e5f691ffa93714545d21) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsCalculationsViewTest.cs (.../MacroStabilityInwardsCalculationsViewTest.cs) (revision d8deffdf2d40b56a90ed729a1c3e9892cfbea7e0) @@ -21,12 +21,15 @@ using System.Collections.Generic; using System.Linq; +using System.Threading; using System.Windows.Forms; using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Controls.DataGrid; using Core.Common.Controls.Views; +using Core.Common.TestUtil; +using Core.Common.Util.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; @@ -148,6 +151,7 @@ Assert.AreEqual("Location 1", hydraulicBoundaryLocationComboboxItems[1].ToString()); Assert.AreEqual("Location 2", hydraulicBoundaryLocationComboboxItems[2].ToString()); } + mocks.VerifyAll(); } @@ -174,6 +178,7 @@ Assert.AreEqual(1, hydraulicBoundaryLocationComboboxItems.Count); Assert.AreEqual("", hydraulicBoundaryLocationComboboxItems[0].ToString()); } + mocks.VerifyAll(); } @@ -204,6 +209,7 @@ Assert.AreEqual("Location 1 (4 m)", hydraulicBoundaryLocationComboboxItems[5].ToString()); Assert.AreEqual("Location 2 (5 m)", hydraulicBoundaryLocationComboboxItems[6].ToString()); } + mocks.VerifyAll(); } @@ -270,6 +276,7 @@ Assert.AreEqual("Model A", stochasticSoilModelsComboboxItems[1].ToString()); Assert.AreEqual("Model E", stochasticSoilModelsComboboxItems[2].ToString()); } + mocks.VerifyAll(); } @@ -297,6 +304,7 @@ Assert.AreEqual("", soilProfilesComboboxItems[0].ToString()); Assert.AreEqual("Profile 5", soilProfilesComboboxItems[1].ToString()); } + mocks.VerifyAll(); } @@ -332,32 +340,45 @@ Assert.AreEqual("30", cells[stochasticSoilProfilesProbabilityColumnIndex].FormattedValue); Assert.AreEqual("Location 2 (5 m)", cells[selectableHydraulicBoundaryLocationsColumnIndex].FormattedValue); } + mocks.VerifyAll(); } [Test] + [Apartment(ApartmentState.STA)] public void MacroStabilityInwardsCalculationsView_SelectingCellInRow_SelectionChangedFired() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - MacroStabilityInwardsCalculationsView macroStabilityInwardsCalculationsView = ShowFullyConfiguredMacroStabilityInwardsCalculationsView( - assessmentSection); + ConfigureHydraulicBoundaryDatabase(assessmentSection); - var selectionChangedCount = 0; - macroStabilityInwardsCalculationsView.SelectionChanged += (sender, args) => selectionChangedCount++; + MacroStabilityInwardsFailureMechanism failureMechanism = ConfigureFailuremechanism(); + using (var calculationsView = new MacroStabilityInwardsCalculationsView + { + AssessmentSection = assessmentSection, + MacroStabilityInwardsFailureMechanism = failureMechanism, + Data = ConfigureCalculationGroup(assessmentSection, failureMechanism) + }) + { + var selectionChangedCount = 0; + calculationsView.SelectionChanged += (sender, args) => selectionChangedCount++; - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - dataGridView.CurrentCell = dataGridView.Rows[0].Cells[0]; + var control = TypeUtils.GetField(calculationsView, "dataGridViewControl"); + WindowsFormsTestHelper.Show(control); - // Call - EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(1, 0)); + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + dataGridView.CurrentCell = dataGridView.Rows[0].Cells[0]; - // Assert - Assert.AreEqual(1, selectionChangedCount); + // Call + EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(1, 0)); + // Assert + Assert.AreEqual(1, selectionChangedCount); + } + WindowsFormsTestHelper.CloseAll(); mocks.VerifyAll(); } @@ -391,6 +412,7 @@ Assert.AreEqual("Calculation 2", dataGridView.Rows[0].Cells[nameColumnIndex].FormattedValue); Assert.AreEqual(2, selectionChangedCount); } + mocks.VerifyAll(); } @@ -861,6 +883,7 @@ var dataRow = (MacroStabilityInwardsCalculationRow) dataGridView.Rows[selectedRow].DataBoundItem; Assert.AreSame(dataRow.MacroStabilityInwardsCalculation, ((MacroStabilityInwardsInputContext) selection).MacroStabilityInwardsCalculation); } + mocks.VerifyAll(); } @@ -901,6 +924,7 @@ // Assert calculation.Output = null; } + mocks.VerifyAll(); } @@ -965,6 +989,7 @@ // Assert calculation.Output = null; } + mocks.VerifyAll(); } @@ -1004,6 +1029,7 @@ var cell = (DataGridViewTextBoxCell) dataGridView.Rows[1].Cells[stochasticSoilProfilesProbabilityColumnIndex]; Assert.AreEqual("50", cell.FormattedValue); } + mocks.VerifyAll(); } @@ -1060,6 +1086,7 @@ Assert.AreEqual("Calculation 1", dataGridView.Rows[0].Cells[nameColumnIndex].FormattedValue); Assert.AreEqual("Calculation 2", dataGridView.Rows[1].Cells[nameColumnIndex].FormattedValue); } + mocks.VerifyAll(); } @@ -1089,6 +1116,7 @@ var currentCellUpdated = (DataGridViewComboBoxCell) dataGridView.Rows[0].Cells[selectableHydraulicBoundaryLocationsColumnIndex]; Assert.AreEqual(useAssessmentLevelManualInput, currentCellUpdated.ReadOnly); } + mocks.VerifyAll(); } Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs =================================================================== diff -u -r005490b7ce22d654f4d1e5f691ffa93714545d21 -rd8deffdf2d40b56a90ed729a1c3e9892cfbea7e0 --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision 005490b7ce22d654f4d1e5f691ffa93714545d21) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationsViewTest.cs (.../PipingCalculationsViewTest.cs) (revision d8deffdf2d40b56a90ed729a1c3e9892cfbea7e0) @@ -22,12 +22,15 @@ using System.Collections.Generic; using System.Globalization; using System.Linq; +using System.Threading; using System.Windows.Forms; using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.Controls.DataGrid; using Core.Common.Controls.Views; +using Core.Common.TestUtil; +using Core.Common.Util.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; @@ -350,28 +353,40 @@ } [Test] + [Apartment(ApartmentState.STA)] public void PipingCalculationsView_SelectingCellInRow_SelectionChangedFired() { // Setup var mocks = new MockRepository(); var assessmentSection = mocks.Stub(); mocks.ReplayAll(); - PipingCalculationsView pipingCalculationsView = ShowFullyConfiguredPipingCalculationsView( - assessmentSection); + ConfigureHydraulicBoundaryDatabase(assessmentSection); - var selectionChangedCount = 0; - pipingCalculationsView.SelectionChanged += (sender, args) => selectionChangedCount++; + PipingFailureMechanism failureMechanism = ConfigureFailuremechanism(); + using (var calculationsView = new PipingCalculationsView + { + AssessmentSection = assessmentSection, + PipingFailureMechanism = failureMechanism, + Data = ConfigureCalculationGroup(assessmentSection, failureMechanism) + }) + { + var selectionChangedCount = 0; + calculationsView.SelectionChanged += (sender, args) => selectionChangedCount++; - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - dataGridView.CurrentCell = dataGridView.Rows[0].Cells[0]; + var control = TypeUtils.GetField(calculationsView, "dataGridViewControl"); + WindowsFormsTestHelper.Show(control); - // Call - EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(1, 0)); + var dataGridView = (DataGridView)new ControlTester("dataGridView").TheObject; + dataGridView.CurrentCell = dataGridView.Rows[0].Cells[0]; - // Assert - Assert.AreEqual(1, selectionChangedCount); + // Call + EventHelper.RaiseEvent(dataGridView, "CellClick", new DataGridViewCellEventArgs(1, 0)); + // Assert + Assert.AreEqual(1, selectionChangedCount); + } + WindowsFormsTestHelper.CloseAll(); mocks.VerifyAll(); }