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