Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs =================================================================== diff -u -r95c3452dca388375373dc915a0fd68acef51833b -r70c6d25383da91912edb6e26dfcb748b1fe361ae --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs) (revision 95c3452dca388375373dc915a0fd68acef51833b) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs (.../GrassCoverErosionOutwardsDesignWaterLevelLocationsViewTest.cs) (revision 70c6d25383da91912edb6e26dfcb748b1fe361ae) @@ -26,6 +26,7 @@ using System.Windows.Forms; using Core.Common.Base; using Core.Common.Base.Geometry; +using Core.Common.Utils.Reflection; using NUnit.Extensions.Forms; using NUnit.Framework; using Rhino.Mocks; @@ -97,7 +98,7 @@ public void Selection_WithLocations_ReturnsSelectedLocationWrappedInContext() { // Call - using (var view = ShowFullyConfiguredDesignWaterLevelLocationsView()) + using (GrassCoverErosionOutwardsDesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView()) { var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; var selectedLocationRow = dataGridView.Rows[0]; @@ -149,6 +150,23 @@ } [Test] + public void DesignWaterLevelLocationsView_AssessmentSection_CorrectlyAttachedAndDetached() + { + // Setup + GrassCoverErosionOutwardsDesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(); + var assessmentSection = mockRepository.StrictMock(); + assessmentSection.Expect(a => a.Attach(null)).IgnoreArguments(); + assessmentSection.Expect(a => a.Detach(null)).IgnoreArguments(); + mockRepository.ReplayAll(); + + // Call + view.AssessmentSection = assessmentSection; + + // Assert + // Assertions based on mock expectancies + } + + [Test] public void DesignWaterLevelLocationsView_WithNonIObservableList_ThrowsInvalidCastException() { // Setup @@ -357,6 +375,37 @@ Assert.DoesNotThrow(test); } + [Test] + [TestCase(false, false, "De bijdrage van dit toetsspoor is nul.")] + [TestCase(true, false, "De bijdrage van dit toetsspoor is nul.")] + [TestCase(false, true, "Er zijn geen berekeningen geselecteerd.")] + [TestCase(true, true, "")] + public void CalculateForSelectedButton_SpecificCombinationOfRowSelectionAndFailureMechanismContributionSet_ButtonAndErrorMessageSyncedAccordingly(bool rowSelected, bool contributionNotZero, string expectedErrorMessage) + { + // Setup & Call + GrassCoverErosionOutwardsDesignWaterLevelLocationsView view = ShowFullyConfiguredDesignWaterLevelLocationsView(); + + if (rowSelected) + { + var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; + var rows = dataGridView.Rows; + rows[0].Cells[locationCalculateColumnIndex].Value = true; + } + + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + if (contributionNotZero) + { + failureMechanism.Contribution = 5; + } + view.FailureMechanism = failureMechanism; + + // Assert + var button = (Button) view.Controls.Find("CalculateForSelectedButton", true)[0]; + Assert.AreEqual(rowSelected && contributionNotZero, button.Enabled); + var errorProvider = TypeUtils.GetField(view, "CalculateForSelectedButtonErrorProvider"); + Assert.AreEqual(expectedErrorMessage, errorProvider.GetError(button)); + } + private GrassCoverErosionOutwardsDesignWaterLevelLocationsView ShowDesignWaterLevelLocationsView() { var view = new GrassCoverErosionOutwardsDesignWaterLevelLocationsView();