Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/PipingStructureSectionResultRow.cs =================================================================== diff -u -rad12f4e2c4a765cc6c20e9f17ac051a99644ec44 -r4c2e1c0b6b1b94e87695a1e439eedfc307f4d374 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/PipingStructureSectionResultRow.cs (.../PipingStructureSectionResultRow.cs) (revision ad12f4e2c4a765cc6c20e9f17ac051a99644ec44) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/PipingStructureSectionResultRow.cs (.../PipingStructureSectionResultRow.cs) (revision 4c2e1c0b6b1b94e87695a1e439eedfc307f4d374) @@ -43,6 +43,22 @@ public PipingStructureSectionResultRow(PipingStructureFailureMechanismSectionResult sectionResult) : base(sectionResult) {} /// + /// Gets or sets the value representing the simple assessment result. + /// + public SimpleAssessmentResultType SimpleAssessmentResult + { + get + { + return SectionResult.SimpleAssessmentInput; + } + set + { + SectionResult.SimpleAssessmentInput = value; + SectionResult.NotifyObservers(); + } + } + + /// /// Gets the assessment layer two a of the . /// public AssessmentLayerTwoAResult AssessmentLayerTwoA Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/PipingStructureResultView.cs =================================================================== diff -u -rca8a0844076cca9cc240f6dec0663604e5dc0c62 -r4c2e1c0b6b1b94e87695a1e439eedfc307f4d374 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/PipingStructureResultView.cs (.../PipingStructureResultView.cs) (revision ca8a0844076cca9cc240f6dec0663604e5dc0c62) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/PipingStructureResultView.cs (.../PipingStructureResultView.cs) (revision 4c2e1c0b6b1b94e87695a1e439eedfc307f4d374) @@ -67,16 +67,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(PipingStructureSectionResultRow.AssessmentLayerOne), + nameof(PipingStructureSectionResultRow.SimpleAssessmentResult), RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one, - layerOneDataSource, + simpleAssessmentDataSource, nameof(EnumDisplayWrapper.Value), nameof(EnumDisplayWrapper.DisplayName)); @@ -97,6 +97,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/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/PipingStructureSectionResultRowTest.cs =================================================================== diff -u -rf4049b9b0967513aeadfddb1fe58efa3b3aa1677 -r4c2e1c0b6b1b94e87695a1e439eedfc307f4d374 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/PipingStructureSectionResultRowTest.cs (.../PipingStructureSectionResultRowTest.cs) (revision f4049b9b0967513aeadfddb1fe58efa3b3aa1677) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/PipingStructureSectionResultRowTest.cs (.../PipingStructureSectionResultRowTest.cs) (revision 4c2e1c0b6b1b94e87695a1e439eedfc307f4d374) @@ -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.SimpleAssessmentResult); Assert.AreEqual(result.AssessmentLayerTwoA, row.AssessmentLayerTwoA); Assert.AreEqual(result.AssessmentLayerThree, row.AssessmentLayerThree); @@ -55,6 +58,32 @@ } [Test] + public void SimpleAssessmentResult_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 PipingStructureFailureMechanismSectionResult(section); + result.Attach(observer); + + var row = new PipingStructureSectionResultRow(result); + + // Call + row.SimpleAssessmentResult = newValue; + + // Assert + Assert.AreEqual(newValue, result.SimpleAssessmentInput); + mocks.VerifyAll(); + } + + [Test] public void AssessmentLayerTwoA_AlwaysOnChange_ResultPropertyChanged() { // Setup Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/PipingStructureResultViewTest.cs =================================================================== diff -u -rca8a0844076cca9cc240f6dec0663604e5dc0c62 -r4c2e1c0b6b1b94e87695a1e439eedfc307f4d374 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/PipingStructureResultViewTest.cs (.../PipingStructureResultViewTest.cs) (revision ca8a0844076cca9cc240f6dec0663604e5dc0c62) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/PipingStructureResultViewTest.cs (.../PipingStructureResultViewTest.cs) (revision 4c2e1c0b6b1b94e87695a1e439eedfc307f4d374) @@ -38,7 +38,7 @@ public class PipingStructureResultViewTest { private const int nameColumnIndex = 0; - private const int assessmentLayerOneIndex = 1; + private const int simpleAssessmentIndex = 1; private const int assessmentLayerTwoAIndex = 2; private const int assessmentLayerThreeIndex = 3; @@ -77,11 +77,11 @@ Assert.AreEqual(4, dataGridView.ColumnCount); - Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerOneIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssessmentIndex]); Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerTwoAIndex]); Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerThreeIndex]); - Assert.AreEqual("Eenvoudige toets", dataGridView.Columns[assessmentLayerOneIndex].HeaderText); + Assert.AreEqual("Eenvoudige toets", dataGridView.Columns[simpleAssessmentIndex].HeaderText); Assert.AreEqual("Gedetailleerde toets per vak", dataGridView.Columns[assessmentLayerTwoAIndex].HeaderText); Assert.AreEqual("Toets op maat", dataGridView.Columns[assessmentLayerThreeIndex].HeaderText); @@ -106,31 +106,42 @@ { new Point2D(0, 0) }); + var section4 = new FailureMechanismSection("Section 4", new[] + { + new Point2D(0, 0) + }); var random = new Random(21); var result1 = new PipingStructureFailureMechanismSectionResult(section1) { - AssessmentLayerOne = AssessmentLayerOneState.Sufficient, + SimpleAssessmentInput = SimpleAssessmentResultType.None, AssessmentLayerTwoA = AssessmentLayerTwoAResult.Failed, AssessmentLayerThree = random.NextRoundedDouble() }; var result2 = new PipingStructureFailureMechanismSectionResult(section2) { - AssessmentLayerOne = AssessmentLayerOneState.NotAssessed, + SimpleAssessmentInput = SimpleAssessmentResultType.NotApplicable, AssessmentLayerTwoA = AssessmentLayerTwoAResult.Successful, AssessmentLayerThree = random.NextRoundedDouble() }; var result3 = new PipingStructureFailureMechanismSectionResult(section3) { - AssessmentLayerOne = AssessmentLayerOneState.NoVerdict, + SimpleAssessmentInput = SimpleAssessmentResultType.ProbabilityNegligible, AssessmentLayerTwoA = AssessmentLayerTwoAResult.Successful, AssessmentLayerThree = random.NextRoundedDouble() }; + var result4 = new PipingStructureFailureMechanismSectionResult(section4) + { + SimpleAssessmentInput = SimpleAssessmentResultType.AssessFurther, + AssessmentLayerTwoA = AssessmentLayerTwoAResult.Successful, + AssessmentLayerThree = random.NextRoundedDouble() + }; var sectionResults = new ObservableList { result1, result2, - result3 + result3, + result4 }; // Call @@ -144,45 +155,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[simpleAssessmentIndex].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[simpleAssessmentIndex].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[simpleAssessmentIndex].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[simpleAssessmentIndex].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 = "FormWithFailureMechanismResultView_SectionPassesLevel0AndListenersNotified_RowsForSectionDisabled(notAssessed)")] - [TestCase(AssessmentLayerOneState.NoVerdict, TestName = "FormWithFailureMechanismResultView_SectionPassesLevel0AndListenersNotified_RowsForSectionDisabled(noVerdict)")] - public void GivenFormWithFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionDisabled( - AssessmentLayerOneState assessmentLayerOneState) + [TestCase(SimpleAssessmentResultType.None)] + [TestCase(SimpleAssessmentResultType.AssessFurther)] + public void GivenFormWithFailureMechanismResultView_WhenSectionPassesSimpleAssessmentAndListenersNotified_ThenRowsForSectionDisabled( + SimpleAssessmentResultType simpleAssessmentResult) { // Given var section = new FailureMechanismSection("Section 1", new[] @@ -192,7 +213,7 @@ var random = new Random(21); var result = new PipingStructureFailureMechanismSectionResult(section) { - AssessmentLayerOne = assessmentLayerOneState, + SimpleAssessmentInput = simpleAssessmentResult, AssessmentLayerTwoA = AssessmentLayerTwoAResult.Failed, AssessmentLayerThree = random.NextRoundedDouble() }; @@ -208,7 +229,7 @@ form.Show(); // When - result.AssessmentLayerOne = AssessmentLayerOneState.Sufficient; + result.SimpleAssessmentInput = SimpleAssessmentResultType.ProbabilityNegligible; result.NotifyObservers(); // Then