Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismResultView.cs =================================================================== diff -u -r27905f2bab6c1d9694143a76cac6e56e371fe13e -r1d71aee3723ff5b847caa193167583cffd985019 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismResultView.cs (.../GrassCoverErosionOutwardsFailureMechanismResultView.cs) (revision 27905f2bab6c1d9694143a76cac6e56e371fe13e) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismResultView.cs (.../GrassCoverErosionOutwardsFailureMechanismResultView.cs) (revision 1d71aee3723ff5b847caa193167583cffd985019) @@ -47,7 +47,6 @@ : base(failureMechanismSectionResults, failureMechanism) { DataGridViewControl.CellFormatting += OnCellFormatting; - UpdateDataGridViewDataSource(); } @@ -67,16 +66,16 @@ { base.AddDataGridColumns(); - EnumDisplayWrapper[] layerOneDataSource = - Enum.GetValues(typeof(AssessmentLayerOneState)) - .OfType() - .Select(sa => new EnumDisplayWrapper(sa)) + EnumDisplayWrapper[] simpleAssessmentDataSource = + Enum.GetValues(typeof(SimpleAssessmentResultType)) + .OfType() + .Select(sa => new EnumDisplayWrapper(sa)) .ToArray(); DataGridViewControl.AddComboBoxColumn( - nameof(GrassCoverErosionOutwardsFailureMechanismSectionResultRow.AssessmentLayerOne), + nameof(GrassCoverErosionOutwardsFailureMechanismSectionResultRow.SimpleAssessmentInput), RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one, - layerOneDataSource, + simpleAssessmentDataSource, nameof(EnumDisplayWrapper.Value), nameof(EnumDisplayWrapper.DisplayName)); @@ -97,6 +96,13 @@ RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three); } + private bool HasPassedSimpleAssessment(int rowIndex) + { + var simpleAssessmentType = (SimpleAssessmentResultType) DataGridViewControl.GetCell(rowIndex, AssessmentLayerOneColumnIndex).Value; + return simpleAssessmentType == SimpleAssessmentResultType.NotApplicable || + simpleAssessmentType == SimpleAssessmentResultType.ProbabilityNegligible; + } + private void OnCellFormatting(object sender, DataGridViewCellFormattingEventArgs eventArgs) { if (eventArgs.ColumnIndex > AssessmentLayerOneColumnIndex) Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismSectionResultRow.cs =================================================================== diff -u -rad12f4e2c4a765cc6c20e9f17ac051a99644ec44 -r1d71aee3723ff5b847caa193167583cffd985019 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismSectionResultRow.cs (.../GrassCoverErosionOutwardsFailureMechanismSectionResultRow.cs) (revision ad12f4e2c4a765cc6c20e9f17ac051a99644ec44) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismSectionResultRow.cs (.../GrassCoverErosionOutwardsFailureMechanismSectionResultRow.cs) (revision 1d71aee3723ff5b847caa193167583cffd985019) @@ -43,6 +43,22 @@ public GrassCoverErosionOutwardsFailureMechanismSectionResultRow(GrassCoverErosionOutwardsFailureMechanismSectionResult sectionResult) : base(sectionResult) {} /// + /// Gets or sets the value representing the simple assessment result. + /// + public SimpleAssessmentResultType SimpleAssessmentInput + { + get + { + return SectionResult.SimpleAssessmentInput; + } + set + { + SectionResult.SimpleAssessmentInput = value; + SectionResult.NotifyObservers(); + } + } + + /// /// Gets or sets the value representing the result of the layer 2a assessment. /// public AssessmentLayerTwoAResult AssessmentLayerTwoA Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs =================================================================== diff -u -r27905f2bab6c1d9694143a76cac6e56e371fe13e -r1d71aee3723ff5b847caa193167583cffd985019 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs) (revision 27905f2bab6c1d9694143a76cac6e56e371fe13e) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs) (revision 1d71aee3723ff5b847caa193167583cffd985019) @@ -108,31 +108,42 @@ { new Point2D(0, 0) }); + var section4 = new FailureMechanismSection("Section 4", new[] + { + new Point2D(0, 0) + }); var random = new Random(21); var result1 = new GrassCoverErosionOutwardsFailureMechanismSectionResult(section1) { - AssessmentLayerOne = AssessmentLayerOneState.Sufficient, + SimpleAssessmentInput = SimpleAssessmentResultType.None, AssessmentLayerTwoA = AssessmentLayerTwoAResult.Failed, AssessmentLayerThree = random.NextRoundedDouble() }; var result2 = new GrassCoverErosionOutwardsFailureMechanismSectionResult(section2) { - AssessmentLayerOne = AssessmentLayerOneState.NotAssessed, + SimpleAssessmentInput = SimpleAssessmentResultType.NotApplicable, AssessmentLayerTwoA = AssessmentLayerTwoAResult.Successful, AssessmentLayerThree = random.NextRoundedDouble() }; var result3 = new GrassCoverErosionOutwardsFailureMechanismSectionResult(section3) { - AssessmentLayerOne = AssessmentLayerOneState.NoVerdict, + SimpleAssessmentInput = SimpleAssessmentResultType.ProbabilityNegligible, AssessmentLayerTwoA = AssessmentLayerTwoAResult.Successful, AssessmentLayerThree = random.NextRoundedDouble() }; + var result4 = new GrassCoverErosionOutwardsFailureMechanismSectionResult(section4) + { + SimpleAssessmentInput = SimpleAssessmentResultType.AssessFurther, + AssessmentLayerTwoA = AssessmentLayerTwoAResult.Successful, + AssessmentLayerThree = random.NextRoundedDouble() + }; var sectionResults = new ObservableList { result1, result2, - result3 + result3, + result4 }; // Call @@ -146,45 +157,55 @@ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; DataGridViewRowCollection rows = dataGridView.Rows; - Assert.AreEqual(3, rows.Count); + Assert.AreEqual(4, rows.Count); DataGridViewCellCollection cells = rows[0].Cells; Assert.AreEqual(4, cells.Count); Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue); - Assert.AreEqual(result1.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value); + Assert.AreEqual(result1.SimpleAssessmentInput, cells[assessmentLayerOneIndex].Value); Assert.AreEqual(result1.AssessmentLayerTwoA, cells[assessmentLayerTwoAIndex].Value); Assert.AreEqual(result1.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); - DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); - DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); + DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]); + DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); cells = rows[1].Cells; Assert.AreEqual(4, cells.Count); Assert.AreEqual("Section 2", cells[nameColumnIndex].FormattedValue); - Assert.AreEqual(result2.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value); + Assert.AreEqual(result2.SimpleAssessmentInput, cells[assessmentLayerOneIndex].Value); Assert.AreEqual(result2.AssessmentLayerTwoA, cells[assessmentLayerTwoAIndex].Value); Assert.AreEqual(result2.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); - DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]); - DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); + DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); + DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); cells = rows[2].Cells; Assert.AreEqual(4, cells.Count); Assert.AreEqual("Section 3", cells[nameColumnIndex].FormattedValue); - Assert.AreEqual(result3.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value); + Assert.AreEqual(result3.SimpleAssessmentInput, cells[assessmentLayerOneIndex].Value); Assert.AreEqual(result3.AssessmentLayerTwoA, cells[assessmentLayerTwoAIndex].Value); Assert.AreEqual(result3.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); + DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); + + cells = rows[3].Cells; + Assert.AreEqual(4, cells.Count); + Assert.AreEqual("Section 4", cells[nameColumnIndex].FormattedValue); + Assert.AreEqual(result4.SimpleAssessmentInput, cells[assessmentLayerOneIndex].Value); + Assert.AreEqual(result4.AssessmentLayerTwoA, cells[assessmentLayerTwoAIndex].Value); + Assert.AreEqual(result4.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]); DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); } } [Test] - [TestCase(AssessmentLayerOneState.NotAssessed, TestName = "ResultView_SectionPassesLevel0_RowsDisabled(notAssessed)")] - [TestCase(AssessmentLayerOneState.NoVerdict, TestName = "ResultView_SectionPassesLevel0_RowsDisabled(noVerdict)")] - public void GivenFormWithFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionBecomesDisabled( - AssessmentLayerOneState assessmentLayerOneState) + [TestCase(SimpleAssessmentResultType.None)] + [TestCase(SimpleAssessmentResultType.AssessFurther)] + public void GivenFormWithFailureMechanismResultView_WhenSectionPassesSimpleAssessmentAndListenersNotified_ThenRowsForSectionBecomesDisabled( + SimpleAssessmentResultType simpleAssessmentResult) { // Given var random = new Random(21); @@ -193,7 +214,7 @@ new Point2D(0, 0) })) { - AssessmentLayerOne = assessmentLayerOneState, + SimpleAssessmentInput = simpleAssessmentResult, AssessmentLayerTwoA = AssessmentLayerTwoAResult.Failed, AssessmentLayerThree = random.NextRoundedDouble() }; @@ -210,7 +231,7 @@ form.Show(); // When - result.AssessmentLayerOne = AssessmentLayerOneState.Sufficient; + result.SimpleAssessmentInput = SimpleAssessmentResultType.ProbabilityNegligible; result.NotifyObservers(); // Then Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismSectionResultRowTest.cs =================================================================== diff -u -rf4049b9b0967513aeadfddb1fe58efa3b3aa1677 -r1d71aee3723ff5b847caa193167583cffd985019 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismSectionResultRowTest.cs (.../GrassCoverErosionOutwardsFailureMechanismSectionResultRowTest.cs) (revision f4049b9b0967513aeadfddb1fe58efa3b3aa1677) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismSectionResultRowTest.cs (.../GrassCoverErosionOutwardsFailureMechanismSectionResultRowTest.cs) (revision 1d71aee3723ff5b847caa193167583cffd985019) @@ -20,9 +20,11 @@ // All rights reserved. using System; +using Core.Common.Base; using Core.Common.Base.Data; using Core.Common.TestUtil; using NUnit.Framework; +using Rhino.Mocks; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.TypeConverters; @@ -47,6 +49,7 @@ // Assert Assert.IsInstanceOf>(row); + Assert.AreEqual(result.SimpleAssessmentInput, row.SimpleAssessmentInput); Assert.AreEqual(result.AssessmentLayerTwoA, row.AssessmentLayerTwoA); Assert.AreEqual(row.AssessmentLayerThree, result.AssessmentLayerThree); @@ -55,6 +58,32 @@ } [Test] + public void SimpleAssessmentInput_SetNewValue_NotifyObserversAndPropertyChanged() + { + // Setup + var mocks = new MockRepository(); + var observer = mocks.StrictMock(); + observer.Expect(o => o.UpdateObserver()); + mocks.ReplayAll(); + + var random = new Random(39); + var newValue = random.NextEnumValue(); + + FailureMechanismSection section = FailureMechanismSectionTestFactory.CreateFailureMechanismSection(); + var result = new GrassCoverErosionOutwardsFailureMechanismSectionResult(section); + result.Attach(observer); + + var row = new GrassCoverErosionOutwardsFailureMechanismSectionResultRow(result); + + // Call + row.SimpleAssessmentInput = newValue; + + // Assert + Assert.AreEqual(newValue, result.SimpleAssessmentInput); + mocks.VerifyAll(); + } + + [Test] public void AssessmentLayerTwoA_AlwaysOnChange_ResultPropertyChanged() { // Setup