Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultCategoriesView.Designer.cs =================================================================== diff -u -r783cff34ad1121a4898d0e9c1928d7397539f97d -r6e00873d8ba2508abd6040c1c7254d4d4bb6ded8 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultCategoriesView.Designer.cs (.../AssemblyResultCategoriesView.Designer.cs) (revision 783cff34ad1121a4898d0e9c1928d7397539f97d) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultCategoriesView.Designer.cs (.../AssemblyResultCategoriesView.Designer.cs) (revision 6e00873d8ba2508abd6040c1c7254d4d4bb6ded8) @@ -30,19 +30,6 @@ /// private System.ComponentModel.IContainer components = null; - /// - /// Clean up any resources being used. - /// - /// true if managed resources should be disposed; otherwise, false. - protected override void Dispose(bool disposing) - { - if (disposing && (components != null)) - { - components.Dispose(); - } - base.Dispose(disposing); - } - #region Component Designer generated code /// Index: Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultCategoriesView.cs =================================================================== diff -u -rebc35a25d5150f2dee8dd31638d462769e0c185f -r6e00873d8ba2508abd6040c1c7254d4d4bb6ded8 --- Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultCategoriesView.cs (.../AssemblyResultCategoriesView.cs) (revision ebc35a25d5150f2dee8dd31638d462769e0c185f) +++ Ringtoets/Integration/src/Ringtoets.Integration.Forms/Views/AssemblyResultCategoriesView.cs (.../AssemblyResultCategoriesView.cs) (revision 6e00873d8ba2508abd6040c1c7254d4d4bb6ded8) @@ -24,6 +24,7 @@ using System.Drawing; using System.Linq; using System.Windows.Forms; +using Core.Common.Base; using Core.Common.Controls.Views; using Ringtoets.AssemblyTool.Data; using Ringtoets.Common.Forms.Helpers; @@ -38,6 +39,9 @@ { private readonly Func> getAssemblyCategoriesFunc; + private readonly Observer assessmentSectionObserver; + private readonly Observer failureMechanismContributionObserver; + /// /// Creates a new instance of . /// @@ -62,13 +66,34 @@ InitializeComponent(); + assessmentSectionObserver = new Observer(UpdateTableData) + { + Observable = assessmentSection + }; + + failureMechanismContributionObserver = new Observer(UpdateTableData) + { + Observable = assessmentSection.FailureMechanismContribution + }; + UpdateTableData(); } public AssessmentSection AssessmentSection { get; } public object Data { get; set; } + protected override void Dispose(bool disposing) + { + if (disposing) + { + assessmentSectionObserver.Dispose(); + failureMechanismContributionObserver.Dispose(); + components?.Dispose(); + } + base.Dispose(disposing); + } + private void UpdateTableData() { assemblyCategoriesTable.SetData( Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssemblyResultCategoriesViewTest.cs =================================================================== diff -u -rebc35a25d5150f2dee8dd31638d462769e0c185f -r6e00873d8ba2508abd6040c1c7254d4d4bb6ded8 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssemblyResultCategoriesViewTest.cs (.../AssemblyResultCategoriesViewTest.cs) (revision ebc35a25d5150f2dee8dd31638d462769e0c185f) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/Views/AssemblyResultCategoriesViewTest.cs (.../AssemblyResultCategoriesViewTest.cs) (revision 6e00873d8ba2508abd6040c1c7254d4d4bb6ded8) @@ -111,6 +111,60 @@ } } + [Test] + public void GivenViewWithValidData_WhenAssessmentSectionUpdated_ThenDataTableUpdated() + { + // Given + var random = new Random(21); + + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var nrOfCategories = 1; + Func> getFailureMechanismCategories = + () => Enumerable.Repeat(CreateRandomFailureMechanismAssemblyCategory(random), nrOfCategories); + + using (var view = new AssemblyResultCategoriesView(assessmentSection, getFailureMechanismCategories)) + { + AssemblyCategoriesTable failureMechanismSectionCategoriesTable = GetFailureMechanismCategoriesTable(view); + + // Precondition + Assert.AreEqual(nrOfCategories, failureMechanismSectionCategoriesTable.Rows.Count); + + // When + nrOfCategories = 2; + assessmentSection.NotifyObservers(); + + // Then + Assert.AreEqual(nrOfCategories, failureMechanismSectionCategoriesTable.Rows.Count); + } + } + + [Test] + public void GivenViewWithValidData_WhenFailureMechanismContributionUpdated_ThenDataTableUpdated() + { + // Given + var random = new Random(21); + + var assessmentSection = new AssessmentSection(AssessmentSectionComposition.Dike); + var nrOfCategories = 1; + Func> getFailureMechanismCategories = + () => Enumerable.Repeat(CreateRandomFailureMechanismAssemblyCategory(random), nrOfCategories); + + using (var view = new AssemblyResultCategoriesView(assessmentSection, getFailureMechanismCategories)) + { + AssemblyCategoriesTable failureMechanismSectionCategoriesTable = GetFailureMechanismCategoriesTable(view); + + // Precondition + Assert.AreEqual(nrOfCategories, failureMechanismSectionCategoriesTable.Rows.Count); + + // When + nrOfCategories = 2; + assessmentSection.FailureMechanismContribution.NotifyObservers(); + + // Then + Assert.AreEqual(nrOfCategories, failureMechanismSectionCategoriesTable.Rows.Count); + } + } + private static AssemblyCategoriesTable GetFailureMechanismCategoriesTable( AssemblyResultCategoriesView view) {