Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs =================================================================== diff -u -r1b9d535d0b4f21bd0adb64184e5273d8bf691c4e -rf93e79beccdd031927870b2db114c8a140e1e3fd --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs) (revision 1b9d535d0b4f21bd0adb64184e5273d8bf691c4e) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs (.../GrassCoverErosionOutwardsWaveHeightLocationsViewTest.cs) (revision f93e79beccdd031927870b2db114c8a140e1e3fd) @@ -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 = ShowFullyConfiguredWaveHeightLocationsView()) + using (GrassCoverErosionOutwardsWaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView()) { var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; var selectedLocationRow = dataGridView.Rows[0]; @@ -145,10 +146,27 @@ } [Test] + public void WaveHeightLocationsView_AssessmentSection_CorrectlyAttachedAndDetached() + { + // Setup + GrassCoverErosionOutwardsWaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(); + 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 WaveHeightLocationsView_WithNonIObservableList_ThrowsInvalidCastException() { // Setup - var view = ShowWaveHeightLocationsView(); + GrassCoverErosionOutwardsWaveHeightLocationsView view = ShowWaveHeightLocationsView(); var locations = new List { @@ -352,6 +370,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 + GrassCoverErosionOutwardsWaveHeightLocationsView view = ShowFullyConfiguredWaveHeightLocationsView(); + + 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 GrassCoverErosionOutwardsWaveHeightLocationsView ShowWaveHeightLocationsView() { var view = new GrassCoverErosionOutwardsWaveHeightLocationsView(); @@ -364,7 +413,7 @@ private GrassCoverErosionOutwardsWaveHeightLocationsView ShowFullyConfiguredWaveHeightLocationsView() { - var view = ShowWaveHeightLocationsView(); + GrassCoverErosionOutwardsWaveHeightLocationsView view = ShowWaveHeightLocationsView(); ObservableList locations = new ObservableList {