Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs =================================================================== diff -u -r2ef5183542af0464fab4ebadb3a6c2c4f7ff46b7 -r18960bc52ca23b3781daea9d4fbc1bedaf6f70f9 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs (.../MacroStabilityOutwardsSectionResultRow.cs) (revision 2ef5183542af0464fab4ebadb3a6c2c4f7ff46b7) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRow.cs (.../MacroStabilityOutwardsSectionResultRow.cs) (revision 18960bc52ca23b3781daea9d4fbc1bedaf6f70f9) @@ -22,6 +22,7 @@ using System; using System.ComponentModel; using Core.Common.Base.Data; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Forms.TypeConverters; using Ringtoets.Common.Forms.Views; using Ringtoets.Integration.Data.StandAlone.SectionResults; @@ -42,6 +43,22 @@ public MacroStabilityOutwardsSectionResultRow(MacroStabilityOutwardsFailureMechanismSectionResult 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 the assessment layer two a of the . /// /// Thrown when is Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MacroStabilityOutwardsResultView.cs =================================================================== diff -u -r087ace1b9736e0c825180366347c82ef35b672e7 -r18960bc52ca23b3781daea9d4fbc1bedaf6f70f9 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MacroStabilityOutwardsResultView.cs (.../MacroStabilityOutwardsResultView.cs) (revision 087ace1b9736e0c825180366347c82ef35b672e7) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MacroStabilityOutwardsResultView.cs (.../MacroStabilityOutwardsResultView.cs) (revision 18960bc52ca23b3781daea9d4fbc1bedaf6f70f9) @@ -43,7 +43,7 @@ /// Creates a new instance of . /// /// - public MacroStabilityOutwardsResultView(IObservableEnumerable failureMechanismSectionResults, + public MacroStabilityOutwardsResultView(IObservableEnumerable failureMechanismSectionResults, MacroStabilityOutwardsFailureMechanism failureMechanism) : base(failureMechanismSectionResults, failureMechanism) { @@ -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(MacroStabilityOutwardsSectionResultRow.AssessmentLayerOne), + nameof(MacroStabilityOutwardsSectionResultRow.SimpleAssessmentInput), RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one, - layerOneDataSource, + simpleAssessmentDataSource, nameof(EnumDisplayWrapper.Value), nameof(EnumDisplayWrapper.DisplayName)); @@ -88,6 +88,19 @@ RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three); } + /// + /// Finds out whether the assessment section which is represented by the row at index + /// has passed the simple assessment. + /// + /// The index of the row which has a section attached. + /// false if the simple assessment has passed, true otherwise. + private bool HasPassedSimpleAssessment(int rowIndex) + { + var simpleAssessmentType = (SimpleAssessmentResultType) DataGridViewControl.GetCell(rowIndex, AssessmentLayerOneColumnIndex).Value; + return simpleAssessmentType == SimpleAssessmentResultType.ProbabilityNegligible + || simpleAssessmentType == SimpleAssessmentResultType.NotApplicable; + } + private void OnCellFormatting(object sender, DataGridViewCellFormattingEventArgs eventArgs) { if (eventArgs.ColumnIndex > AssessmentLayerOneColumnIndex) Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRowTest.cs =================================================================== diff -u -r2ef5183542af0464fab4ebadb3a6c2c4f7ff46b7 -r18960bc52ca23b3781daea9d4fbc1bedaf6f70f9 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRowTest.cs (.../MacroStabilityOutwardsSectionResultRowTest.cs) (revision 2ef5183542af0464fab4ebadb3a6c2c4f7ff46b7) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/MacroStabilityOutwardsSectionResultRowTest.cs (.../MacroStabilityOutwardsSectionResultRowTest.cs) (revision 18960bc52ca23b3781daea9d4fbc1bedaf6f70f9) @@ -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(result.AssessmentLayerThree, row.AssessmentLayerThree); @@ -59,6 +62,33 @@ } [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 MacroStabilityOutwardsFailureMechanismSectionResult(section); + result.Attach(observer); + + var row = new MacroStabilityOutwardsSectionResultRow(result); + + // Call + row.SimpleAssessmentInput = newValue; + + // Assert + Assert.AreEqual(newValue, result.SimpleAssessmentInput); + + mocks.VerifyAll(); + } + + [Test] [TestCase(0)] [TestCase(1)] [TestCase(0.5)] Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/MacrostabilityOutwardsResultViewTest.cs =================================================================== diff -u -r087ace1b9736e0c825180366347c82ef35b672e7 -r18960bc52ca23b3781daea9d4fbc1bedaf6f70f9 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/MacrostabilityOutwardsResultViewTest.cs (.../MacrostabilityOutwardsResultViewTest.cs) (revision 087ace1b9736e0c825180366347c82ef35b672e7) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/MacrostabilityOutwardsResultViewTest.cs (.../MacrostabilityOutwardsResultViewTest.cs) (revision 18960bc52ca23b3781daea9d4fbc1bedaf6f70f9) @@ -39,7 +39,7 @@ public class MacroStabilityOutwardsResultViewTest { 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; @@ -65,7 +65,7 @@ { // Given using (var form = new Form()) - using (var view = new MacroStabilityOutwardsResultView(new ObservableList(), + using (var view = new MacroStabilityOutwardsResultView(new ObservableList(), new MacroStabilityOutwardsFailureMechanism())) { form.Controls.Add(view); @@ -76,11 +76,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); @@ -105,31 +105,42 @@ { new Point2D(0, 0) }); + var section4 = new FailureMechanismSection("Section 4", new[] + { + new Point2D(0, 0) + }); var random = new Random(21); var result1 = new MacroStabilityOutwardsFailureMechanismSectionResult(section1) { - AssessmentLayerOne = AssessmentLayerOneState.Sufficient, + SimpleAssessmentInput = SimpleAssessmentResultType.None, AssessmentLayerTwoA = random.NextRoundedDouble(), AssessmentLayerThree = random.NextRoundedDouble() }; var result2 = new MacroStabilityOutwardsFailureMechanismSectionResult(section2) { - AssessmentLayerOne = AssessmentLayerOneState.NotAssessed, + SimpleAssessmentInput = SimpleAssessmentResultType.NotApplicable, AssessmentLayerTwoA = random.NextRoundedDouble(), AssessmentLayerThree = random.NextRoundedDouble() }; var result3 = new MacroStabilityOutwardsFailureMechanismSectionResult(section3) { - AssessmentLayerOne = AssessmentLayerOneState.NoVerdict, + SimpleAssessmentInput = SimpleAssessmentResultType.ProbabilityNegligible, AssessmentLayerTwoA = random.NextRoundedDouble(), AssessmentLayerThree = random.NextRoundedDouble() }; + var result4 = new MacroStabilityOutwardsFailureMechanismSectionResult(section4) + { + SimpleAssessmentInput = SimpleAssessmentResultType.AssessFurther, + AssessmentLayerTwoA = random.NextRoundedDouble(), + AssessmentLayerThree = random.NextRoundedDouble() + }; var sectionResults = new ObservableList { result1, result2, - result3 + result3, + result4 }; // Call @@ -142,48 +153,59 @@ // Assert 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); string expectedAssessmentLayer2AString1 = ProbabilityFormattingHelper.Format(result1.AssessmentLayerTwoA); Assert.AreEqual(expectedAssessmentLayer2AString1, cells[assessmentLayerTwoAIndex].FormattedValue); 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); string expectedAssessmentLayer2AString2 = ProbabilityFormattingHelper.Format(result2.AssessmentLayerTwoA); Assert.AreEqual(expectedAssessmentLayer2AString2, cells[assessmentLayerTwoAIndex].FormattedValue); 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); string expectedAssessmentLayer2AString3 = ProbabilityFormattingHelper.Format(result3.AssessmentLayerTwoA); Assert.AreEqual(expectedAssessmentLayer2AString3, cells[assessmentLayerTwoAIndex].FormattedValue); 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); + string expectedAssessmentLayer2AString4 = ProbabilityFormattingHelper.Format(result4.AssessmentLayerTwoA); + Assert.AreEqual(expectedAssessmentLayer2AString4, cells[assessmentLayerTwoAIndex].FormattedValue); + 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, TestName = "FormWithFailureMechanismResultView_SectionPassesLevel0AndListenersNotified_RowsForSectionDisabled(notAssessed)")] + [TestCase(SimpleAssessmentResultType.AssessFurther, TestName = "FormWithFailureMechanismResultView_SectionPassesLevel0AndListenersNotified_RowsForSectionDisabled(noVerdict)")] + public void GivenFormWithFailureMechanismResultView_WhenSectionPassesSimpleAssessmentAndListenersNotified_ThenRowsForSectionDisabled( + SimpleAssessmentResultType simpleAssessmentResult) { // Given var random = new Random(21); @@ -192,7 +214,7 @@ new Point2D(0, 0) })) { - AssessmentLayerOne = assessmentLayerOneState, + SimpleAssessmentInput = simpleAssessmentResult, AssessmentLayerTwoA = random.NextRoundedDouble(), AssessmentLayerThree = random.NextRoundedDouble() }; @@ -208,7 +230,7 @@ form.Show(); // When - result.AssessmentLayerOne = AssessmentLayerOneState.Sufficient; + result.SimpleAssessmentInput = SimpleAssessmentResultType.ProbabilityNegligible; result.NotifyObservers(); // Then Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismSectionResultRow.cs =================================================================== diff -u -r6d6256a21a3a1bc8e4811db1eb638df3cfb4c37b -r18960bc52ca23b3781daea9d4fbc1bedaf6f70f9 --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismSectionResultRow.cs (.../MacroStabilityInwardsFailureMechanismSectionResultRow.cs) (revision 6d6256a21a3a1bc8e4811db1eb638df3cfb4c37b) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismSectionResultRow.cs (.../MacroStabilityInwardsFailureMechanismSectionResultRow.cs) (revision 18960bc52ca23b3781daea9d4fbc1bedaf6f70f9) @@ -79,7 +79,7 @@ } /// - /// Gets or sets the value representing whether the section passed the simple assessment. + /// Gets or sets the value representing the simple assessment result. /// public SimpleAssessmentResultType SimpleAssessmentInput { Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismSectionResultRowTest.cs =================================================================== diff -u -r6d6256a21a3a1bc8e4811db1eb638df3cfb4c37b -r18960bc52ca23b3781daea9d4fbc1bedaf6f70f9 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismSectionResultRowTest.cs (.../MacroStabilityInwardsFailureMechanismSectionResultRowTest.cs) (revision 6d6256a21a3a1bc8e4811db1eb638df3cfb4c37b) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismSectionResultRowTest.cs (.../MacroStabilityInwardsFailureMechanismSectionResultRowTest.cs) (revision 18960bc52ca23b3781daea9d4fbc1bedaf6f70f9) @@ -59,6 +59,7 @@ // Assert Assert.IsInstanceOf>(row); + Assert.AreEqual(row.SimpleAssessmentInput, result.SimpleAssessmentInput); Assert.AreEqual(result.GetAssessmentLayerTwoA(Enumerable.Empty(), failureMechanism, assessmentSection), row.AssessmentLayerTwoA); Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Integration.Test/MacroStabilityInwardsFailureMechanismResultViewIntegrationTest.cs =================================================================== diff -u -r7c037110f82f8b11269ece9edeef02c7f4d59c9b -r18960bc52ca23b3781daea9d4fbc1bedaf6f70f9 --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Integration.Test/MacroStabilityInwardsFailureMechanismResultViewIntegrationTest.cs (.../MacroStabilityInwardsFailureMechanismResultViewIntegrationTest.cs) (revision 7c037110f82f8b11269ece9edeef02c7f4d59c9b) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Integration.Test/MacroStabilityInwardsFailureMechanismResultViewIntegrationTest.cs (.../MacroStabilityInwardsFailureMechanismResultViewIntegrationTest.cs) (revision 18960bc52ca23b3781daea9d4fbc1bedaf6f70f9) @@ -51,9 +51,9 @@ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); var failureMechanismResultView = new MacroStabilityInwardsFailureMechanismResultView( - assessmentSection.MacroStabilityInwards.SectionResults, - assessmentSection.MacroStabilityInwards, - assessmentSection); + assessmentSection.MacroStabilityInwards.SectionResults, + assessmentSection.MacroStabilityInwards, + assessmentSection); form.Controls.Add(failureMechanismResultView); form.Show(); Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismSectionResultRow.cs =================================================================== diff -u -r74e362128e21e414c29a561f6e6fe113bcab2635 -r18960bc52ca23b3781daea9d4fbc1bedaf6f70f9 --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismSectionResultRow.cs (.../PipingFailureMechanismSectionResultRow.cs) (revision 74e362128e21e414c29a561f6e6fe113bcab2635) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismSectionResultRow.cs (.../PipingFailureMechanismSectionResultRow.cs) (revision 18960bc52ca23b3781daea9d4fbc1bedaf6f70f9) @@ -79,7 +79,7 @@ } /// - /// Gets or sets the value representing whether the section passed the simple assessment. + /// Gets or sets the value representing the simple assessment result. /// public SimpleAssessmentResultType SimpleAssessmentInput {