Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/TechnicalInnovationSectionResultRow.cs =================================================================== diff -u -rad12f4e2c4a765cc6c20e9f17ac051a99644ec44 -r365b6aa8cc0ff51af4551cc4b540a65cb6247b93 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/TechnicalInnovationSectionResultRow.cs (.../TechnicalInnovationSectionResultRow.cs) (revision ad12f4e2c4a765cc6c20e9f17ac051a99644ec44) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultRows/TechnicalInnovationSectionResultRow.cs (.../TechnicalInnovationSectionResultRow.cs) (revision 365b6aa8cc0ff51af4551cc4b540a65cb6247b93) @@ -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 TechnicalInnovationSectionResultRow(TechnicalInnovationFailureMechanismSectionResult 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 or sets the value of the tailored assessment of safety. /// [TypeConverter(typeof(NoValueRoundedDoubleConverter))] Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/TechnicalInnovationResultView.cs =================================================================== diff -u -r081c5e6d61bd9581f8d1c205a51127ac8019b9ee -r365b6aa8cc0ff51af4551cc4b540a65cb6247b93 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/TechnicalInnovationResultView.cs (.../TechnicalInnovationResultView.cs) (revision 081c5e6d61bd9581f8d1c205a51127ac8019b9ee) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/TechnicalInnovationResultView.cs (.../TechnicalInnovationResultView.cs) (revision 365b6aa8cc0ff51af4551cc4b540a65cb6247b93) @@ -43,7 +43,7 @@ /// Creates a new instance of . /// /// - public TechnicalInnovationResultView(IObservableEnumerable failureMechanismSectionResults, + public TechnicalInnovationResultView(IObservableEnumerable failureMechanismSectionResults, TechnicalInnovationFailureMechanism 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(TechnicalInnovationSectionResultRow.AssessmentLayerOne), + nameof(TechnicalInnovationSectionResultRow.SimpleAssessmentResult), RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one, - layerOneDataSource, + simpleAssessmentDataSource, nameof(EnumDisplayWrapper.Value), nameof(EnumDisplayWrapper.DisplayName)); @@ -85,6 +85,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/TechnicalInnovationSectionResultRowTest.cs =================================================================== diff -u -rf4049b9b0967513aeadfddb1fe58efa3b3aa1677 -r365b6aa8cc0ff51af4551cc4b540a65cb6247b93 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/TechnicalInnovationSectionResultRowTest.cs (.../TechnicalInnovationSectionResultRowTest.cs) (revision f4049b9b0967513aeadfddb1fe58efa3b3aa1677) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultRows/TechnicalInnovationSectionResultRowTest.cs (.../TechnicalInnovationSectionResultRowTest.cs) (revision 365b6aa8cc0ff51af4551cc4b540a65cb6247b93) @@ -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,13 +49,40 @@ // Assert Assert.IsInstanceOf>(row); + Assert.AreEqual(result.SimpleAssessmentInput, row.SimpleAssessmentResult); Assert.AreEqual(result.AssessmentLayerThree, row.AssessmentLayerThree); TestHelper.AssertTypeConverter( nameof(TechnicalInnovationSectionResultRow.AssessmentLayerThree)); } [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 TechnicalInnovationFailureMechanismSectionResult(section); + result.Attach(observer); + + var row = new TechnicalInnovationSectionResultRow(result); + + // Call + row.SimpleAssessmentResult = newValue; + + // Assert + Assert.AreEqual(newValue, result.SimpleAssessmentInput); + mocks.VerifyAll(); + } + + [Test] public void AssessmentLayerThree_AlwaysOnChange_ResultPropertyChanged() { // Setup Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/TechnicalInnovationResultViewTest.cs =================================================================== diff -u -r081c5e6d61bd9581f8d1c205a51127ac8019b9ee -r365b6aa8cc0ff51af4551cc4b540a65cb6247b93 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/TechnicalInnovationResultViewTest.cs (.../TechnicalInnovationResultViewTest.cs) (revision 081c5e6d61bd9581f8d1c205a51127ac8019b9ee) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/TechnicalInnovationResultViewTest.cs (.../TechnicalInnovationResultViewTest.cs) (revision 365b6aa8cc0ff51af4551cc4b540a65cb6247b93) @@ -38,7 +38,7 @@ public class TechnicalInnovationResultViewTest { private const int nameColumnIndex = 0; - private const int assessmentLayerOneIndex = 1; + private const int simpleAssessmentIndex = 1; private const int assessmentLayerThreeIndex = 2; [Test] @@ -76,10 +76,10 @@ Assert.AreEqual(3, dataGridView.ColumnCount); - Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerOneIndex]); + Assert.IsInstanceOf(dataGridView.Columns[simpleAssessmentIndex]); Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerThreeIndex]); - Assert.AreEqual("Eenvoudige toets", dataGridView.Columns[assessmentLayerOneIndex].HeaderText); + Assert.AreEqual("Eenvoudige toets", dataGridView.Columns[simpleAssessmentIndex].HeaderText); Assert.AreEqual("Toets op maat", dataGridView.Columns[assessmentLayerThreeIndex].HeaderText); Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); @@ -103,28 +103,38 @@ { new Point2D(0, 0) }); + var section4 = new FailureMechanismSection("Section 4", new[] + { + new Point2D(0, 0) + }); var random = new Random(21); var result1 = new TechnicalInnovationFailureMechanismSectionResult(section1) { - AssessmentLayerOne = AssessmentLayerOneState.Sufficient, + SimpleAssessmentInput = SimpleAssessmentResultType.None, AssessmentLayerThree = random.NextRoundedDouble() }; var result2 = new TechnicalInnovationFailureMechanismSectionResult(section2) { - AssessmentLayerOne = AssessmentLayerOneState.NotAssessed, + SimpleAssessmentInput = SimpleAssessmentResultType.NotApplicable, AssessmentLayerThree = random.NextRoundedDouble() }; var result3 = new TechnicalInnovationFailureMechanismSectionResult(section3) { - AssessmentLayerOne = AssessmentLayerOneState.NoVerdict, + SimpleAssessmentInput = SimpleAssessmentResultType.ProbabilityNegligible, AssessmentLayerThree = random.NextRoundedDouble() }; + var result4 = new TechnicalInnovationFailureMechanismSectionResult(section4) + { + SimpleAssessmentInput = SimpleAssessmentResultType.AssessFurther, + AssessmentLayerThree = random.NextRoundedDouble() + }; var sectionResults = new ObservableList { result1, result2, - result3 + result3, + result4 }; // Call @@ -138,39 +148,47 @@ 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(3, 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.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); - DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); + DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); cells = rows[1].Cells; Assert.AreEqual(3, 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.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); - DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); + DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); cells = rows[2].Cells; Assert.AreEqual(3, 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.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); + + cells = rows[3].Cells; + Assert.AreEqual(3, cells.Count); + Assert.AreEqual("Section 4", cells[nameColumnIndex].FormattedValue); + Assert.AreEqual(result4.SimpleAssessmentInput, cells[simpleAssessmentIndex].Value); + Assert.AreEqual(result4.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + 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[] @@ -180,7 +198,7 @@ var random = new Random(21); var result = new TechnicalInnovationFailureMechanismSectionResult(section) { - AssessmentLayerOne = assessmentLayerOneState, + SimpleAssessmentInput = simpleAssessmentResult, AssessmentLayerThree = random.NextRoundedDouble() }; var sectionResults = new ObservableList @@ -195,7 +213,7 @@ form.Show(); // When - result.AssessmentLayerOne = AssessmentLayerOneState.Sufficient; + result.SimpleAssessmentInput = SimpleAssessmentResultType.ProbabilityNegligible; result.NotifyObservers(); // Then