Index: Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismResultView.cs =================================================================== diff -u -r5785cc13c0454eaabed7ede4dad8e885db7efd50 -r08864bba0658cfabadff39a42013580b5bbb0447 --- Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismResultView.cs (.../GrassCoverErosionOutwardsFailureMechanismResultView.cs) (revision 5785cc13c0454eaabed7ede4dad8e885db7efd50) +++ Ringtoets/GrassCoverErosionOutwards/src/Ringtoets.GrassCoverErosionOutwards.Forms/Views/GrassCoverErosionOutwardsFailureMechanismResultView.cs (.../GrassCoverErosionOutwardsFailureMechanismResultView.cs) (revision 08864bba0658cfabadff39a42013580b5bbb0447) @@ -21,11 +21,9 @@ using System; using System.Linq; -using System.Windows.Forms; using Core.Common.Base; using Core.Common.Util; using Ringtoets.Common.Data.FailureMechanism; -using Ringtoets.Common.Forms.Helpers; using Ringtoets.Common.Forms.Views; using Ringtoets.Common.Primitives; using Ringtoets.GrassCoverErosionOutwards.Data; @@ -53,13 +51,6 @@ return new GrassCoverErosionOutwardsFailureMechanismSectionResultRow(sectionResult); } - protected override void Dispose(bool disposing) - { - DataGridViewControl.CellFormatting -= OnCellFormatting; - - base.Dispose(disposing); - } - protected override void AddDataGridColumns() { DataGridViewControl.AddTextBoxColumn( @@ -96,28 +87,5 @@ nameof(GrassCoverErosionOutwardsFailureMechanismSectionResultRow.AssessmentLayerThree), RingtoetsCommonFormsResources.FailureMechanismResultView_TailorMadeAssessmentResult_DisplayName); } - - protected override void BindEvents() - { - base.BindEvents(); - - DataGridViewControl.CellFormatting += OnCellFormatting; - } - - private void OnCellFormatting(object sender, DataGridViewCellFormattingEventArgs eventArgs) - { - if (eventArgs.ColumnIndex > SimpleAssessmentColumnIndex) - { - SimpleAssessmentResultType simpleAssessmentResult = GetDataAtRow(eventArgs.RowIndex).SimpleAssessmentResult; - if (FailureMechanismSectionResultRowHelper.SimpleAssessmentIsSufficient(simpleAssessmentResult)) - { - DataGridViewControl.DisableCell(eventArgs.RowIndex, eventArgs.ColumnIndex); - } - else - { - DataGridViewControl.RestoreCell(eventArgs.RowIndex, eventArgs.ColumnIndex); - } - } - } } } \ No newline at end of file Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs =================================================================== diff -u -r44420c717ac32101ba0da4739d259c622f47976e -r08864bba0658cfabadff39a42013580b5bbb0447 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs) (revision 44420c717ac32101ba0da4739d259c622f47976e) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/Views/GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs (.../GrassCoverErosionOutwardsFailureMechanismResultViewTest.cs) (revision 08864bba0658cfabadff39a42013580b5bbb0447) @@ -19,10 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. -using System; using System.Windows.Forms; -using Core.Common.Base; -using Core.Common.TestUtil; using NUnit.Extensions.Forms; using NUnit.Framework; using Ringtoets.Common.Data.FailureMechanism; @@ -61,7 +58,7 @@ } [Test] - public void GivenFormWithGrassCoverErosionOutwardsFailureMechanismResultView_WhenShown_ThenExpectedColumnsAreVisible() + public void GivenFormWithFailureMechanismResultView_ThenExpectedColumnsAreVisible() { // Given var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); @@ -93,49 +90,15 @@ } [Test] - public void GrassCoverErosionOutwardsFailureMechanismResultView_WithFailureMechanismSectionResultAssigned_SectionsAddedAsRows() + public void FailureMechanismResultsView_AllDataSet_DataGridViewCorrectlyInitialized() { // Setup - var random = new Random(21); - var result1 = new GrassCoverErosionOutwardsFailureMechanismSectionResult( - FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1")) - { - SimpleAssessmentResult = SimpleAssessmentResultType.None, - AssessmentLayerTwoA = AssessmentLayerTwoAResult.Failed, - AssessmentLayerThree = random.NextRoundedDouble() - }; - var result2 = new GrassCoverErosionOutwardsFailureMechanismSectionResult( - FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 2")) - { - SimpleAssessmentResult = SimpleAssessmentResultType.NotApplicable, - AssessmentLayerTwoA = AssessmentLayerTwoAResult.Successful, - AssessmentLayerThree = random.NextRoundedDouble() - }; - var result3 = new GrassCoverErosionOutwardsFailureMechanismSectionResult( - FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 3")) - { - SimpleAssessmentResult = SimpleAssessmentResultType.ProbabilityNegligible, - AssessmentLayerTwoA = AssessmentLayerTwoAResult.Successful, - AssessmentLayerThree = random.NextRoundedDouble() - }; - var result4 = new GrassCoverErosionOutwardsFailureMechanismSectionResult( - FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 4")) - { - SimpleAssessmentResult = SimpleAssessmentResultType.AssessFurther, - AssessmentLayerTwoA = AssessmentLayerTwoAResult.Successful, - AssessmentLayerThree = random.NextRoundedDouble() - }; - var sectionResults = new ObservableList - { - result1, - result2, - result3, - result4 - }; + var failureMechanism = new GrassCoverErosionOutwardsFailureMechanism(); + failureMechanism.AddSection(FailureMechanismSectionTestFactory.CreateFailureMechanismSection("Section 1")); // Call using (var form = new Form()) - using (var view = new GrassCoverErosionOutwardsFailureMechanismResultView(sectionResults, new GrassCoverErosionOutwardsFailureMechanism())) + using (var view = new GrassCoverErosionOutwardsFailureMechanismResultView(failureMechanism.SectionResults, failureMechanism)) { form.Controls.Add(view); form.Show(); @@ -144,91 +107,15 @@ var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; DataGridViewRowCollection rows = dataGridView.Rows; - Assert.AreEqual(4, rows.Count); + Assert.AreEqual(1, rows.Count); DataGridViewCellCollection cells = rows[0].Cells; Assert.AreEqual(4, cells.Count); Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue); - Assert.AreEqual(result1.SimpleAssessmentResult, cells[simpleAssessmentIndex].Value); - Assert.AreEqual(result1.AssessmentLayerTwoA, cells[assessmentLayerTwoAIndex].Value); - Assert.AreEqual(result1.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); - - 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.SimpleAssessmentResult, cells[simpleAssessmentIndex].Value); - Assert.AreEqual(result2.AssessmentLayerTwoA, cells[assessmentLayerTwoAIndex].Value); - Assert.AreEqual(result2.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); - - 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.SimpleAssessmentResult, 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.SimpleAssessmentResult, 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]); + Assert.AreEqual(SimpleAssessmentResultType.None, cells[simpleAssessmentIndex].Value); + Assert.AreEqual(AssessmentLayerTwoAResult.NotCalculated, cells[assessmentLayerTwoAIndex].Value); + Assert.AreEqual("-", cells[assessmentLayerThreeIndex].FormattedValue); } } - - [Test] - [TestCase(SimpleAssessmentResultType.None)] - [TestCase(SimpleAssessmentResultType.AssessFurther)] - public void GivenFormWithFailureMechanismResultView_WhenSectionPassesSimpleAssessmentAndListenersNotified_ThenRowsForSectionBecomesDisabled( - SimpleAssessmentResultType simpleAssessmentResult) - { - // Given - var random = new Random(21); - var result = new GrassCoverErosionOutwardsFailureMechanismSectionResult( - FailureMechanismSectionTestFactory.CreateFailureMechanismSection()) - { - SimpleAssessmentResult = simpleAssessmentResult, - AssessmentLayerTwoA = AssessmentLayerTwoAResult.Failed, - AssessmentLayerThree = random.NextRoundedDouble() - }; - var sectionResults = new ObservableList - { - result - }; - - using (var form = new Form()) - using (var view = new GrassCoverErosionOutwardsFailureMechanismResultView(sectionResults, new GrassCoverErosionOutwardsFailureMechanism())) - { - form.Controls.Add(view); - form.Show(); - - // When - result.SimpleAssessmentResult = SimpleAssessmentResultType.ProbabilityNegligible; - result.NotifyObservers(); - - // Then - var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; - DataGridViewRowCollection rows = dataGridView.Rows; - Assert.AreEqual(1, rows.Count); - - DataGridViewCellCollection cells = rows[0].Cells; - Assert.AreEqual(4, cells.Count); - - DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); - DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); - } - } } } \ No newline at end of file