Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/StrengthStabilityLengthwiseConstructionResultViewTest.cs =================================================================== diff -u -r2973c5f790a5131e427bd5f73e2a620044199639 -r72df29ed5129df80e9266cb712f8c92cc54ab045 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/StrengthStabilityLengthwiseConstructionResultViewTest.cs (.../StrengthStabilityLengthwiseConstructionResultViewTest.cs) (revision 2973c5f790a5131e427bd5f73e2a620044199639) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/SectionResultViews/StrengthStabilityLengthwiseConstructionResultViewTest.cs (.../StrengthStabilityLengthwiseConstructionResultViewTest.cs) (revision 72df29ed5129df80e9266cb712f8c92cc54ab045) @@ -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 { @@ -56,11 +55,11 @@ Assert.AreEqual(3, dataGridView.ColumnCount); - Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerOneIndex]); + Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerOneIndex]); Assert.IsInstanceOf(dataGridView.Columns[assessmentLayerThreeIndex]); - Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_one, dataGridView.Columns[assessmentLayerOneIndex].HeaderText); - Assert.AreEqual(RingtoetsCommonFormsResources.FailureMechanismResultView_InitializeDataGridView_Assessment_layer_three, dataGridView.Columns[assessmentLayerThreeIndex].HeaderText); + Assert.AreEqual("Toetslaag 1", dataGridView.Columns[assessmentLayerOneIndex].HeaderText); + Assert.AreEqual("Toetslaag 3", dataGridView.Columns[assessmentLayerThreeIndex].HeaderText); Assert.AreEqual(DataGridViewAutoSizeColumnsMode.AllCells, dataGridView.AutoSizeColumnsMode); Assert.AreEqual(DataGridViewContentAlignment.MiddleCenter, dataGridView.ColumnHeadersDefaultCellStyle.Alignment); @@ -79,17 +78,27 @@ { new Point2D(0, 0) }); + var section3 = new FailureMechanismSection("Section 3", new[] + { + new Point2D(0, 0) + }); + Random random = new Random(21); var result1 = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(section1) { - AssessmentLayerOne = true, + AssessmentLayerOne = AssessmentLayerOneState.Sufficient, AssessmentLayerThree = (RoundedDouble) random.NextDouble() }; var result2 = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(section2) { - AssessmentLayerOne = false, + AssessmentLayerOne = AssessmentLayerOneState.NotAssessed, AssessmentLayerThree = (RoundedDouble) random.NextDouble() }; + var result3 = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(section3) + { + AssessmentLayerOne = AssessmentLayerOneState.NeedsDetailedAssessment, + AssessmentLayerThree = (RoundedDouble) random.NextDouble() + }; using (var form = new Form()) using (var view = new StrengthStabilityLengthwiseConstructionResultView()) @@ -101,34 +110,46 @@ 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(3, cells.Count); Assert.AreEqual("Section 1", cells[nameColumnIndex].FormattedValue); Assert.AreEqual(result1.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value); Assert.AreEqual(result1.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); - AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); + DataGridViewCellTester.AssertCellIsDisabled(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.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); - AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); + DataGridViewCellTester.AssertCellIsEnabled(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.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + + DataGridViewCellTester.AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); } } [Test] - public void GivenFormWithStrengthStabilityLengthwiseConstructionFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionBecomesDisabled() + [TestCase(AssessmentLayerOneState.NotAssessed)] + [TestCase(AssessmentLayerOneState.NeedsDetailedAssessment)] + public void GivenFormWithStrengthStabilityLengthwiseConstructionFailureMechanismResultView_WhenSectionPassesLevel0AndListenersNotified_ThenRowsForSectionBecomesDisabled( + AssessmentLayerOneState assessmentLayerOneState) { // Given var section = new FailureMechanismSection("Section 1", new[] @@ -138,7 +159,7 @@ Random random = new Random(21); var result = new StrengthStabilityLengthwiseConstructionFailureMechanismSectionResult(section) { - AssessmentLayerOne = false, + AssessmentLayerOne = assessmentLayerOneState, AssessmentLayerThree = (RoundedDouble) random.NextDouble() }; using (var form = new Form()) @@ -153,7 +174,7 @@ }; // When - result.AssessmentLayerOne = true; + result.AssessmentLayerOne = AssessmentLayerOneState.Sufficient; result.NotifyObservers(); // Then @@ -164,7 +185,7 @@ var cells = rows[0].Cells; Assert.AreEqual(3, cells.Count); - AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); + DataGridViewCellTester.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); } } @@ -202,19 +223,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