Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MacrostabilityInwardsResultView.cs =================================================================== diff -u -r9a196c8bc554a2e97ff094d7ffb2e99c42eb04fd -r2af1aa9fd18b312ecad33f2e85ca803821b3f615 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MacrostabilityInwardsResultView.cs (.../MacrostabilityInwardsResultView.cs) (revision 9a196c8bc554a2e97ff094d7ffb2e99c42eb04fd) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MacrostabilityInwardsResultView.cs (.../MacrostabilityInwardsResultView.cs) (revision 2af1aa9fd18b312ecad33f2e85ca803821b3f615) @@ -41,8 +41,6 @@ public MacrostabilityInwardsResultView() { DataGridViewControl.AddCellFormattingHandler(OnCellFormatting); - - AddDataGridColumns(); } protected override object CreateFailureMechanismSectionResultRow(MacrostabilityInwardsFailureMechanismSectionResult sectionResult) @@ -57,16 +55,11 @@ base.Dispose(disposing); } - private void AddDataGridColumns() + protected override void AddDataGridColumns() { + base.AddDataGridColumns(); + DataGridViewControl.AddTextBoxColumn( - TypeUtils.GetMemberName(sr => sr.Name), - RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Section_name, - true); - DataGridViewControl.AddCheckBoxColumn( - TypeUtils.GetMemberName(sr => sr.AssessmentLayerOne), - RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one); - DataGridViewControl.AddTextBoxColumn( TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoA), RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a); DataGridViewControl.AddTextBoxColumn( Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MacrostabilityOutwardsResultView.cs =================================================================== diff -u -r9a196c8bc554a2e97ff094d7ffb2e99c42eb04fd -r2af1aa9fd18b312ecad33f2e85ca803821b3f615 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MacrostabilityOutwardsResultView.cs (.../MacrostabilityOutwardsResultView.cs) (revision 9a196c8bc554a2e97ff094d7ffb2e99c42eb04fd) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MacrostabilityOutwardsResultView.cs (.../MacrostabilityOutwardsResultView.cs) (revision 2af1aa9fd18b312ecad33f2e85ca803821b3f615) @@ -41,8 +41,6 @@ public MacrostabilityOutwardsResultView() { DataGridViewControl.AddCellFormattingHandler(OnCellFormatting); - - AddDataGridColumns(); } protected override object CreateFailureMechanismSectionResultRow(MacrostabilityOutwardsFailureMechanismSectionResult sectionResult) @@ -57,16 +55,11 @@ base.Dispose(disposing); } - private void AddDataGridColumns() + protected override void AddDataGridColumns() { + base.AddDataGridColumns(); + DataGridViewControl.AddTextBoxColumn( - TypeUtils.GetMemberName(sr => sr.Name), - RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Section_name, - true); - DataGridViewControl.AddCheckBoxColumn( - TypeUtils.GetMemberName(sr => sr.AssessmentLayerOne), - RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one); - DataGridViewControl.AddTextBoxColumn( TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoA), RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a); DataGridViewControl.AddTextBoxColumn( Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MicrostabilityResultView.cs =================================================================== diff -u -r9a196c8bc554a2e97ff094d7ffb2e99c42eb04fd -r2af1aa9fd18b312ecad33f2e85ca803821b3f615 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MicrostabilityResultView.cs (.../MicrostabilityResultView.cs) (revision 9a196c8bc554a2e97ff094d7ffb2e99c42eb04fd) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/SectionResultViews/MicrostabilityResultView.cs (.../MicrostabilityResultView.cs) (revision 2af1aa9fd18b312ecad33f2e85ca803821b3f615) @@ -45,8 +45,6 @@ public MicrostabilityResultView() { DataGridViewControl.AddCellFormattingHandler(OnCellFormatting); - - AddDataGridColumns(); } protected override object CreateFailureMechanismSectionResultRow(MicrostabilityFailureMechanismSectionResult sectionResult) @@ -61,36 +59,16 @@ base.Dispose(disposing); } - private void OnCellFormatting(object sender, DataGridViewCellFormattingEventArgs eventArgs) + protected override void AddDataGridColumns() { - if (eventArgs.ColumnIndex > assessmentLayerOneColumnIndex) - { - if (HasPassedLevelOne(eventArgs.RowIndex)) - { - DataGridViewControl.DisableCell(eventArgs.RowIndex, eventArgs.ColumnIndex); - } - else - { - DataGridViewControl.RestoreCell(eventArgs.RowIndex, eventArgs.ColumnIndex); - } - } - } + base.AddDataGridColumns(); - private void AddDataGridColumns() - { EnumDisplayWrapper[] twoAResultDataSource = Enum.GetValues(typeof(AssessmentLayerTwoAResult)) .OfType() .Select(el => new EnumDisplayWrapper(el)) .ToArray(); - DataGridViewControl.AddTextBoxColumn( - TypeUtils.GetMemberName(sr => sr.Name), - RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Section_name, - true); - DataGridViewControl.AddCheckBoxColumn( - TypeUtils.GetMemberName(sr => sr.AssessmentLayerOne), - RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one); DataGridViewControl.AddComboBoxColumn( TypeUtils.GetMemberName(sr => sr.AssessmentLayerTwoA), RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a, @@ -101,5 +79,20 @@ TypeUtils.GetMemberName(sr => sr.AssessmentLayerThree), RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three); } + + private void OnCellFormatting(object sender, DataGridViewCellFormattingEventArgs eventArgs) + { + if (eventArgs.ColumnIndex > assessmentLayerOneColumnIndex) + { + if (HasPassedLevelOne(eventArgs.RowIndex)) + { + DataGridViewControl.DisableCell(eventArgs.RowIndex, eventArgs.ColumnIndex); + } + else + { + DataGridViewControl.RestoreCell(eventArgs.RowIndex, eventArgs.ColumnIndex); + } + } + } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/MacrostabilityInwardsResultViewTest.cs =================================================================== diff -u -r2973c5f790a5131e427bd5f73e2a620044199639 -r2af1aa9fd18b312ecad33f2e85ca803821b3f615 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/MacrostabilityInwardsResultViewTest.cs (.../MacrostabilityInwardsResultViewTest.cs) (revision 2973c5f790a5131e427bd5f73e2a620044199639) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/MacrostabilityInwardsResultViewTest.cs (.../MacrostabilityInwardsResultViewTest.cs) (revision 2af1aa9fd18b312ecad33f2e85ca803821b3f615) @@ -20,7 +20,6 @@ // All rights reserved. using System; -using System.Drawing; using System.Windows.Forms; using Core.Common.Base.Data; using Core.Common.Base.Geometry; @@ -29,10 +28,9 @@ using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.Helpers; +using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Integration.Data.StandAlone.SectionResults; using Ringtoets.Integration.Forms.Views.SectionResultViews; -using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; -using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; namespace Ringtoets.Integration.Forms.Test.Views.SectionResultViews { @@ -59,19 +57,13 @@ Assert.AreEqual(4, dataGridView.ColumnCount); - Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerOneIndex]); + Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerOneIndex]); Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerTwoAIndex]); Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerThreeIndex]); - Assert.AreEqual( - RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one, - dataGridView.Columns[assessmentLayerOneIndex].HeaderText); - Assert.AreEqual( - RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a, - dataGridView.Columns[assessmentLayerTwoAIndex].HeaderText); - Assert.AreEqual( - RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three, - dataGridView.Columns[assessmentLayerThreeIndex].HeaderText); + Assert.AreEqual("Toetslaag 1", dataGridView.Columns[assessmentLayerOneIndex].HeaderText); + Assert.AreEqual("Toetslaag 2a", dataGridView.Columns[assessmentLayerTwoAIndex].HeaderText); + Assert.AreEqual("Toetslaag 3", dataGridView.Columns[assessmentLayerThreeIndex].HeaderText); Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); @@ -90,19 +82,30 @@ { new Point2D(0, 0) }); + var section3 = new FailureMechanismSection("Section 3", new[] + { + new Point2D(0, 0) + }); + Random random = new Random(21); var result1 = new MacrostabilityInwardsFailureMechanismSectionResult(section1) { - AssessmentLayerOne = true, + AssessmentLayerOne = AssessmentLayerOneState.Sufficient, AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), AssessmentLayerThree = (RoundedDouble) random.NextDouble() }; var result2 = new MacrostabilityInwardsFailureMechanismSectionResult(section2) { - AssessmentLayerOne = false, + AssessmentLayerOne = AssessmentLayerOneState.NotAssessed, AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), AssessmentLayerThree = (RoundedDouble) random.NextDouble() }; + var result3 = new MacrostabilityInwardsFailureMechanismSectionResult(section3) + { + AssessmentLayerOne = AssessmentLayerOneState.NeedsDetailedAssessment, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; using (var form = new Form()) using (var view = new MacrostabilityInwardsResultView()) @@ -114,13 +117,14 @@ view.Data = new[] { result1, - result2 + result2, + result3 }; // Then var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; var rows = dataGridView.Rows; - Assert.AreEqual(2, rows.Count); + Assert.AreEqual(3, rows.Count); var cells = rows[0].Cells; Assert.AreEqual(4, cells.Count); @@ -130,8 +134,8 @@ Assert.AreEqual(expectedAssessmentLayer2AString1, cells[assessmentLayerTwoAIndex].FormattedValue); Assert.AreEqual(result1.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); - AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); - AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); + DataGridViewCellTester.AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); + DataGridViewCellTester.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); cells = rows[1].Cells; Assert.AreEqual(4, cells.Count); @@ -141,13 +145,24 @@ Assert.AreEqual(expectedAssessmentLayer2AString2, cells[assessmentLayerTwoAIndex].FormattedValue); Assert.AreEqual(result2.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); - AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]); - AssertCellIsEnabled(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); + var expectedAssessmentLayer2AString3 = ProbabilityFormattingHelper.Format(result3.AssessmentLayerTwoA); + Assert.AreEqual(expectedAssessmentLayer2AString3, cells[assessmentLayerTwoAIndex].FormattedValue); + Assert.AreEqual(result3.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + + DataGridViewCellTester.AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]); + DataGridViewCellTester.AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); } } [Test] - public void GivenFormWithMacrostabilityInwardsFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionBecomesDisabled() + [TestCase(AssessmentLayerOneState.NotAssessed)] + [TestCase(AssessmentLayerOneState.NeedsDetailedAssessment)] + public void GivenFormWithMacrostabilityInwardsFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionBecomesDisabled( + AssessmentLayerOneState assessmentLayerOneState) { // Given var section = new FailureMechanismSection("Section 1", new[] @@ -157,7 +172,7 @@ Random random = new Random(21); var result = new MacrostabilityInwardsFailureMechanismSectionResult(section) { - AssessmentLayerOne = false, + AssessmentLayerOne = assessmentLayerOneState, AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), AssessmentLayerThree = (RoundedDouble) random.NextDouble() }; @@ -173,7 +188,7 @@ }; // When - result.AssessmentLayerOne = true; + result.AssessmentLayerOne = AssessmentLayerOneState.Sufficient; result.NotifyObservers(); // Then @@ -184,8 +199,8 @@ var cells = rows[0].Cells; Assert.AreEqual(4, cells.Count); - AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); - AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); + DataGridViewCellTester.AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); + DataGridViewCellTester.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); } } @@ -223,19 +238,5 @@ Assert.AreEqual(0, rows.Count); } } - - private void AssertCellIsDisabled(DataGridViewCell dataGridViewCell) - { - Assert.AreEqual(true, dataGridViewCell.ReadOnly); - Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), dataGridViewCell.Style.ForeColor); - Assert.AreEqual(Color.FromKnownColor(KnownColor.DarkGray), dataGridViewCell.Style.BackColor); - } - - private void AssertCellIsEnabled(DataGridViewCell dataGridViewCell) - { - Assert.AreEqual(false, dataGridViewCell.ReadOnly); - Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), dataGridViewCell.Style.ForeColor); - Assert.AreEqual(Color.FromKnownColor(KnownColor.White), dataGridViewCell.Style.BackColor); - } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/MacrostabilityOutwardsResultViewTest.cs =================================================================== diff -u -r2973c5f790a5131e427bd5f73e2a620044199639 -r2af1aa9fd18b312ecad33f2e85ca803821b3f615 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/MacrostabilityOutwardsResultViewTest.cs (.../MacrostabilityOutwardsResultViewTest.cs) (revision 2973c5f790a5131e427bd5f73e2a620044199639) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/MacrostabilityOutwardsResultViewTest.cs (.../MacrostabilityOutwardsResultViewTest.cs) (revision 2af1aa9fd18b312ecad33f2e85ca803821b3f615) @@ -20,7 +20,6 @@ // All rights reserved. using System; -using System.Drawing; using System.Windows.Forms; using Core.Common.Base.Data; using Core.Common.Base.Geometry; @@ -29,10 +28,9 @@ using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Forms.Helpers; +using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Integration.Data.StandAlone.SectionResults; using Ringtoets.Integration.Forms.Views.SectionResultViews; -using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; -using CoreCommonBaseResources = Core.Common.Base.Properties.Resources; namespace Ringtoets.Integration.Forms.Test.Views.SectionResultViews { @@ -59,19 +57,13 @@ Assert.AreEqual(4, dataGridView.ColumnCount); - Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerOneIndex]); + Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerOneIndex]); Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerTwoAIndex]); Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerThreeIndex]); - Assert.AreEqual( - RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one, - dataGridView.Columns[assessmentLayerOneIndex].HeaderText); - Assert.AreEqual( - RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a, - dataGridView.Columns[assessmentLayerTwoAIndex].HeaderText); - Assert.AreEqual( - RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three, - dataGridView.Columns[assessmentLayerThreeIndex].HeaderText); + Assert.AreEqual("Toetslaag 1", dataGridView.Columns[assessmentLayerOneIndex].HeaderText); + Assert.AreEqual("Toetslaag 2a", dataGridView.Columns[assessmentLayerTwoAIndex].HeaderText); + Assert.AreEqual("Toetslaag 3", dataGridView.Columns[assessmentLayerThreeIndex].HeaderText); Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); @@ -90,19 +82,30 @@ { new Point2D(0, 0) }); + var section3 = new FailureMechanismSection("Section 3", new[] + { + new Point2D(0, 0) + }); + Random random = new Random(21); var result1 = new MacrostabilityOutwardsFailureMechanismSectionResult(section1) { - AssessmentLayerOne = true, + AssessmentLayerOne = AssessmentLayerOneState.Sufficient, AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), AssessmentLayerThree = (RoundedDouble) random.NextDouble() }; var result2 = new MacrostabilityOutwardsFailureMechanismSectionResult(section2) { - AssessmentLayerOne = false, + AssessmentLayerOne = AssessmentLayerOneState.NotAssessed, AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), AssessmentLayerThree = (RoundedDouble) random.NextDouble() }; + var result3 = new MacrostabilityOutwardsFailureMechanismSectionResult(section3) + { + AssessmentLayerOne = AssessmentLayerOneState.NeedsDetailedAssessment, + AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; using (var form = new Form()) using (var view = new MacrostabilityOutwardsResultView()) @@ -114,13 +117,14 @@ view.Data = new[] { result1, - result2 + result2, + result3 }; // Then var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; var rows = dataGridView.Rows; - Assert.AreEqual(2, rows.Count); + Assert.AreEqual(3, rows.Count); var cells = rows[0].Cells; Assert.AreEqual(4, cells.Count); @@ -130,8 +134,8 @@ Assert.AreEqual(expectedAssessmentLayer2AString1, cells[assessmentLayerTwoAIndex].FormattedValue); Assert.AreEqual(result1.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); - AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); - AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); + DataGridViewCellTester.AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); + DataGridViewCellTester.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); cells = rows[1].Cells; Assert.AreEqual(4, cells.Count); @@ -141,13 +145,27 @@ Assert.AreEqual(expectedAssessmentLayer2AString2, cells[assessmentLayerTwoAIndex].FormattedValue); Assert.AreEqual(result2.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); - AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]); - AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); + DataGridViewCellTester.AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]); + DataGridViewCellTester.AssertCellIsEnabled(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); + var expectedAssessmentLayer2AString3 = ProbabilityFormattingHelper.Format(result3.AssessmentLayerTwoA); + Assert.AreEqual(expectedAssessmentLayer2AString3, cells[assessmentLayerTwoAIndex].FormattedValue); + Assert.AreEqual(result3.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + + DataGridViewCellTester.AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]); + DataGridViewCellTester.AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); } } [Test] - public void GivenFormWithMacrostabilityOutwardsFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionBecomesDisabled() + [TestCase(AssessmentLayerOneState.NotAssessed)] + [TestCase(AssessmentLayerOneState.NeedsDetailedAssessment)] + public void GivenFormWithMacrostabilityOutwardsFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionBecomesDisabled( + AssessmentLayerOneState assessmentLayerOneState) { // Given var section = new FailureMechanismSection("Section 1", new[] @@ -157,7 +175,7 @@ Random random = new Random(21); var result = new MacrostabilityOutwardsFailureMechanismSectionResult(section) { - AssessmentLayerOne = false, + AssessmentLayerOne = assessmentLayerOneState, AssessmentLayerTwoA = (RoundedDouble) random.NextDouble(), AssessmentLayerThree = (RoundedDouble) random.NextDouble() }; @@ -173,7 +191,7 @@ }; // When - result.AssessmentLayerOne = true; + result.AssessmentLayerOne = AssessmentLayerOneState.Sufficient; result.NotifyObservers(); // Then @@ -184,8 +202,8 @@ var cells = rows[0].Cells; Assert.AreEqual(4, cells.Count); - AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); - AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); + DataGridViewCellTester.AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); + DataGridViewCellTester.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); } } @@ -223,19 +241,5 @@ Assert.AreEqual(0, rows.Count); } } - - private void AssertCellIsDisabled(DataGridViewCell dataGridViewCell) - { - Assert.AreEqual(true, dataGridViewCell.ReadOnly); - Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), dataGridViewCell.Style.ForeColor); - Assert.AreEqual(Color.FromKnownColor(KnownColor.DarkGray), dataGridViewCell.Style.BackColor); - } - - private void AssertCellIsEnabled(DataGridViewCell dataGridViewCell) - { - Assert.AreEqual(false, dataGridViewCell.ReadOnly); - Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), dataGridViewCell.Style.ForeColor); - Assert.AreEqual(Color.FromKnownColor(KnownColor.White), dataGridViewCell.Style.BackColor); - } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/MicrostabilityResultViewTest.cs =================================================================== diff -u -r2973c5f790a5131e427bd5f73e2a620044199639 -r2af1aa9fd18b312ecad33f2e85ca803821b3f615 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/MicrostabilityResultViewTest.cs (.../MicrostabilityResultViewTest.cs) (revision 2973c5f790a5131e427bd5f73e2a620044199639) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/MicrostabilityResultViewTest.cs (.../MicrostabilityResultViewTest.cs) (revision 2af1aa9fd18b312ecad33f2e85ca803821b3f615) @@ -20,17 +20,16 @@ // All rights reserved. using System; -using System.Drawing; using System.Windows.Forms; using Core.Common.Base.Data; using Core.Common.Base.Geometry; using NUnit.Extensions.Forms; using NUnit.Framework; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Forms.TestUtil; using Ringtoets.Integration.Data.StandAlone.SectionResults; using Ringtoets.Integration.Forms.Views.SectionResultViews; -using RingtoetsCommonFormsResources = Ringtoets.Common.Forms.Properties.Resources; namespace Ringtoets.Integration.Forms.Test.Views.SectionResultViews { @@ -59,13 +58,13 @@ Assert.AreEqual(4, dataGridView.ColumnCount); - Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerOneIndex]); + Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerOneIndex]); Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerTwoAIndex]); Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerThreeIndex]); - Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one, dataGridView.Columns[assessmentLayerOneIndex].HeaderText); - Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_two_a, dataGridView.Columns[assessmentLayerTwoAIndex].HeaderText); - Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three, dataGridView.Columns[assessmentLayerThreeIndex].HeaderText); + Assert.AreEqual("Toetslaag 1", dataGridView.Columns[assessmentLayerOneIndex].HeaderText); + Assert.AreEqual("Toetslaag 2a", dataGridView.Columns[assessmentLayerTwoAIndex].HeaderText); + Assert.AreEqual("Toetslaag 3", dataGridView.Columns[assessmentLayerThreeIndex].HeaderText); Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); @@ -84,19 +83,30 @@ { new Point2D(0, 0) }); + var section3 = new FailureMechanismSection("Section 3", new[] + { + new Point2D(0, 0) + }); + Random random = new Random(21); var result1 = new MicrostabilityFailureMechanismSectionResult(section1) { - AssessmentLayerOne = true, + AssessmentLayerOne = AssessmentLayerOneState.Sufficient, AssessmentLayerTwoA = AssessmentLayerTwoAResult.Failed, AssessmentLayerThree = (RoundedDouble) random.NextDouble() }; var result2 = new MicrostabilityFailureMechanismSectionResult(section2) { - AssessmentLayerOne = false, + AssessmentLayerOne = AssessmentLayerOneState.NotAssessed, AssessmentLayerTwoA = AssessmentLayerTwoAResult.Successful, AssessmentLayerThree = (RoundedDouble) random.NextDouble() }; + var result3 = new MicrostabilityFailureMechanismSectionResult(section3) + { + AssessmentLayerOne = AssessmentLayerOneState.NeedsDetailedAssessment, + AssessmentLayerTwoA = AssessmentLayerTwoAResult.Successful, + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; using (var form = new Form()) using (var view = new MicrostabilityResultView()) @@ -108,14 +118,15 @@ view.Data = new[] { result1, - result2 + result2, + result3 }; // Then var dataGridView = (DataGridView) new ControlTester("dataGridView").TheObject; var rows = dataGridView.Rows; - Assert.AreEqual(2, rows.Count); + Assert.AreEqual(3, rows.Count); var cells = rows[0].Cells; Assert.AreEqual(4, cells.Count); @@ -124,8 +135,8 @@ Assert.AreEqual(result1.AssessmentLayerTwoA, cells[assessmentLayerTwoAIndex].Value); Assert.AreEqual(result1.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); - AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); - AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); + DataGridViewCellTester.AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); + DataGridViewCellTester.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); cells = rows[1].Cells; Assert.AreEqual(4, cells.Count); @@ -134,13 +145,26 @@ Assert.AreEqual(result2.AssessmentLayerTwoA, cells[assessmentLayerTwoAIndex].Value); Assert.AreEqual(result2.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); - AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]); - AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); + DataGridViewCellTester.AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]); + DataGridViewCellTester.AssertCellIsEnabled(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.AssessmentLayerTwoA, cells[assessmentLayerTwoAIndex].Value); + Assert.AreEqual(result3.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + + DataGridViewCellTester.AssertCellIsEnabled(cells[assessmentLayerTwoAIndex]); + DataGridViewCellTester.AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); } } [Test] - public void GivenFormWithMicrostabilityFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionBecomesDisabled() + [TestCase(AssessmentLayerOneState.NotAssessed)] + [TestCase(AssessmentLayerOneState.NeedsDetailedAssessment)] + public void GivenFormWithMicrostabilityFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionBecomesDisabled( + AssessmentLayerOneState assessmentLayerOneState) { // Given var section = new FailureMechanismSection("Section 1", new[] @@ -150,7 +174,7 @@ Random random = new Random(21); var result = new MicrostabilityFailureMechanismSectionResult(section) { - AssessmentLayerOne = false, + AssessmentLayerOne = assessmentLayerOneState, AssessmentLayerTwoA = AssessmentLayerTwoAResult.Failed, AssessmentLayerThree = (RoundedDouble) random.NextDouble() }; @@ -166,7 +190,7 @@ }; // When - result.AssessmentLayerOne = true; + result.AssessmentLayerOne = AssessmentLayerOneState.Sufficient; result.NotifyObservers(); // Then @@ -177,8 +201,8 @@ var cells = rows[0].Cells; Assert.AreEqual(4, cells.Count); - AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); - AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); + DataGridViewCellTester.AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); + DataGridViewCellTester.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); } } @@ -216,19 +240,5 @@ Assert.AreEqual(0, rows.Count); } } - - private void AssertCellIsDisabled(DataGridViewCell dataGridViewCell) - { - Assert.AreEqual(true, dataGridViewCell.ReadOnly); - Assert.AreEqual(Color.FromKnownColor(KnownColor.GrayText), dataGridViewCell.Style.ForeColor); - Assert.AreEqual(Color.FromKnownColor(KnownColor.DarkGray), dataGridViewCell.Style.BackColor); - } - - private void AssertCellIsEnabled(DataGridViewCell dataGridViewCell) - { - Assert.AreEqual(false, dataGridViewCell.ReadOnly); - Assert.AreEqual(Color.FromKnownColor(KnownColor.ControlText), dataGridViewCell.Style.ForeColor); - Assert.AreEqual(Color.FromKnownColor(KnownColor.White), dataGridViewCell.Style.BackColor); - } } } \ No newline at end of file