Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultCategoriesView.cs =================================================================== diff -u -r4f29c5e0442b0ab7f72ec2d3fd40759d33c77aea -rebc35a25d5150f2dee8dd31638d462769e0c185f --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultCategoriesView.cs (.../AssemblyResultCategoriesView.cs) (revision 4f29c5e0442b0ab7f72ec2d3fd40759d33c77aea) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultCategoriesView.cs (.../AssemblyResultCategoriesView.cs) (revision ebc35a25d5150f2dee8dd31638d462769e0c185f) @@ -21,9 +21,12 @@ using System; using System.Collections.Generic; +using System.Drawing; +using System.Linq; using System.Windows.Forms; using Core.Common.Controls.Views; using Ringtoets.AssemblyTool.Data; +using Ringtoets.Common.Forms.Helpers; using Ringtoets.Integration.Data; namespace Ringtoets.Integration.Forms.Views @@ -33,6 +36,8 @@ /// public partial class AssemblyResultCategoriesView : UserControl, IView { + private readonly Func> getAssemblyCategoriesFunc; + /// /// Creates a new instance of . /// @@ -52,13 +57,26 @@ throw new ArgumentNullException(nameof(getAssemblyCategoriesFunc)); } + AssessmentSection = assessmentSection; + this.getAssemblyCategoriesFunc = getAssemblyCategoriesFunc; + InitializeComponent(); - AssessmentSection = assessmentSection; + UpdateTableData(); } public AssessmentSection AssessmentSection { get; } public object Data { get; set; } + + private void UpdateTableData() + { + assemblyCategoriesTable.SetData( + getAssemblyCategoriesFunc().Select( + category => new Tuple( + category, + AssemblyCategoryGroupColorHelper.GetFailureMechanismAssemblyCategoryGroupColor(category.Group), + category.Group)).ToArray()); + } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssemblyResultCategoriesViewTest.cs =================================================================== diff -u -r783cff34ad1121a4898d0e9c1928d7397539f97d -rebc35a25d5150f2dee8dd31638d462769e0c185f --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssemblyResultCategoriesViewTest.cs (.../AssemblyResultCategoriesViewTest.cs) (revision 783cff34ad1121a4898d0e9c1928d7397539f97d) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssemblyResultCategoriesViewTest.cs (.../AssemblyResultCategoriesViewTest.cs) (revision ebc35a25d5150f2dee8dd31638d462769e0c185f) @@ -20,9 +20,11 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Linq; using System.Windows.Forms; using Core.Common.Controls.Views; +using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.AssemblyTool.Data; using Ringtoets.Common.Data.AssessmentSection; @@ -64,7 +66,7 @@ var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); // Call - using (var view = new AssemblyResultCategoriesView(assessmentSection, () => null)) + using (var view = new AssemblyResultCategoriesView(assessmentSection, Enumerable.Empty)) { // Assert Assert.IsInstanceOf(view); @@ -83,16 +85,44 @@ Assert.AreEqual(DockStyle.Fill, groupBox.Dock); Assert.AreEqual("Categoriegrenzen voor de gecombineerde toetssporen 1 en 2", groupBox.Text); - AssemblyCategoriesTable failureMechanismSectionCategoriesTable = GetFailureMechanismSectionCategoriesTable(view); + AssemblyCategoriesTable failureMechanismSectionCategoriesTable = GetFailureMechanismCategoriesTable(view); Assert.AreEqual(DockStyle.Fill, failureMechanismSectionCategoriesTable.Dock); } } - private static AssemblyCategoriesTable GetFailureMechanismSectionCategoriesTable( + [Test] + public void Constructor_WithValidParameters_FillTableWithData() + { + // Setup + var random = new Random(21); + + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + const int nrOfCategories = 1; + Func> getAssemblyCategoriesFunc = + () => Enumerable.Repeat(CreateRandomFailureMechanismAssemblyCategory(random), nrOfCategories); + + // Call + using (var view = new AssemblyResultCategoriesView(assessmentSection, getAssemblyCategoriesFunc)) + { + AssemblyCategoriesTable failureMechanismSectionCategoriesTable = GetFailureMechanismCategoriesTable(view); + + // Assert + Assert.AreEqual(nrOfCategories, failureMechanismSectionCategoriesTable.Rows.Count); + } + } + + private static AssemblyCategoriesTable GetFailureMechanismCategoriesTable( AssemblyResultCategoriesView view) { return ControlTestHelper.GetControls>( view, "assemblyCategoriesTable").Single(); } + + private static FailureMechanismAssemblyCategory CreateRandomFailureMechanismAssemblyCategory(Random random) + { + return new FailureMechanismAssemblyCategory(random.NextDouble(), + random.NextDouble(), + random.NextEnumValue()); + } } } \ No newline at end of file Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/MacroStabilityOutwardsAssemblyCategoriesViewTest.cs =================================================================== diff -u -rba46b2d15caa390a7bbf642e4816d06fc00a3fac -rebc35a25d5150f2dee8dd31638d462769e0c185f --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/MacroStabilityOutwardsAssemblyCategoriesViewTest.cs (.../MacroStabilityOutwardsAssemblyCategoriesViewTest.cs) (revision ba46b2d15caa390a7bbf642e4816d06fc00a3fac) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/MacroStabilityOutwardsAssemblyCategoriesViewTest.cs (.../MacroStabilityOutwardsAssemblyCategoriesViewTest.cs) (revision ebc35a25d5150f2dee8dd31638d462769e0c185f) @@ -77,7 +77,7 @@ } [Test] - public void Constructor_WithValidParameters_CreatesViewAndTableWithData() + public void Constructor_WithValidParameters_ExpectedValues() { // Setup var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); @@ -114,6 +114,36 @@ } [Test] + public void Constructor_WithValidParameters_FillTableWithData() + { + // Setup + var random = new Random(21); + + var mocks = new MockRepository(); + var assessmentSection = mocks.Stub(); + mocks.ReplayAll(); + + var failureMechanism = new MacroStabilityOutwardsFailureMechanism(); + + const int nrOfCategories = 1; + Func> getFailureMechanismSectionCategories = + () => Enumerable.Repeat(CreateRandomFailureMechanismSectionAssemblyCategory(random), nrOfCategories); + + // Call + using (var view = new MacroStabilityOutwardsAssemblyCategoriesView(failureMechanism, + assessmentSection, + getFailureMechanismSectionCategories)) + { + AssemblyCategoriesTable failureMechanismSectionCategoriesTable = GetFailureMechanismSectionCategoriesTable(view); + + // Assert + Assert.AreEqual(nrOfCategories, failureMechanismSectionCategoriesTable.Rows.Count); + } + + mocks.VerifyAll(); + } + + [Test] public void GivenViewWithValidData_WhenFailureMechanismUpdated_ThenDataTableUpdated() { // Given