Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/FailureMechanismSectionsViewTest.cs =================================================================== diff -u -r52647e3599ba4ba250975f3f81fbfe3f75beb0a0 -rbcd4906ba69493851a366ac7a94f4281133f3dab --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/FailureMechanismSectionsViewTest.cs (.../FailureMechanismSectionsViewTest.cs) (revision 52647e3599ba4ba250975f3f81fbfe3f75beb0a0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/FailureMechanismSectionsViewTest.cs (.../FailureMechanismSectionsViewTest.cs) (revision bcd4906ba69493851a366ac7a94f4281133f3dab) @@ -147,18 +147,7 @@ // Assert DataGridViewControl sectionsTable = GetSectionsTable(view); - Assert.AreEqual(sections.Length, sectionsTable.Rows.Count); - - for (var i = 0; i < sectionsTable.Rows.Count; i++) - { - FailureMechanismSection section = sections[i]; - DataGridViewCellCollection rowCells = sectionsTable.Rows[i].Cells; - - Assert.AreEqual(section.Name, rowCells[nameColumnIndex].Value); - - var sectionLength = (RoundedDouble) rowCells[lengthColumnIndex].Value; - Assert.AreEqual(section.Length, sectionLength, sectionLength.GetAccuracy()); - } + AssertSectionsTable(sections, sectionsTable); } mocks.VerifyAll(); @@ -176,29 +165,46 @@ DataGridViewControl sectionsTable = GetSectionsTable(view); // Precondition - Assert.AreEqual(1, sectionsTable.Rows.Count); + AssertSectionsTable(failureMechanism.Sections.ToArray(), sectionsTable); // When failureMechanism.AddSection(CreateFailureMechanismSection("b")); failureMechanism.NotifyObservers(); // Then - Assert.AreEqual(2, sectionsTable.Rows.Count); + AssertSectionsTable(failureMechanism.Sections.ToArray(), sectionsTable); } } - private static DataGridViewControl GetSectionsTable(FailureMechanismSectionsView view) - { - return ControlTestHelper.GetControls(view, "failureMechanismSectionsTable").Single(); - } - private static FailureMechanismSection CreateFailureMechanismSection(string name) { var random = new Random(39); + return new FailureMechanismSection(name, new[] { new Point2D(random.NextDouble(), random.NextDouble()) }); } + + private static DataGridViewControl GetSectionsTable(FailureMechanismSectionsView view) + { + return ControlTestHelper.GetControls(view, "failureMechanismSectionsTable").Single(); + } + + private static void AssertSectionsTable(FailureMechanismSection[] sections, DataGridViewControl sectionsTable) + { + Assert.AreEqual(sections.Length, sectionsTable.Rows.Count); + + for (var i = 0; i < sectionsTable.Rows.Count; i++) + { + FailureMechanismSection section = sections[i]; + DataGridViewCellCollection rowCells = sectionsTable.Rows[i].Cells; + + Assert.AreEqual(section.Name, rowCells[nameColumnIndex].Value); + + var sectionLength = (RoundedDouble) rowCells[lengthColumnIndex].Value; + Assert.AreEqual(section.Length, sectionLength, sectionLength.GetAccuracy()); + } + } } } \ No newline at end of file