Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputView.cs =================================================================== diff -u -r8f4f49daca3074460478b3236bde0511fb7fbe56 -r8a563ecfb400fafa392d2b849c597a99e3acac8c --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputView.cs (.../MacroStabilityInwardsOutputView.cs) (revision 8f4f49daca3074460478b3236bde0511fb7fbe56) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsOutputView.cs (.../MacroStabilityInwardsOutputView.cs) (revision 8a563ecfb400fafa392d2b849c597a99e3acac8c) @@ -32,6 +32,7 @@ public partial class MacroStabilityInwardsOutputView : UserControl, IChartView { private readonly Observer outputObserver; + private readonly Observer inputObserver; private MacroStabilityInwardsCalculationScenario data; @@ -43,6 +44,7 @@ InitializeComponent(); outputObserver = new Observer(UpdateChartData); + inputObserver = new Observer(UpdateChartData); } public object Data @@ -56,6 +58,7 @@ data = value as MacroStabilityInwardsCalculationScenario; outputObserver.Observable = data; + inputObserver.Observable = data?.InputParameters; macroStabilityInwardsOutputChartControl.Data = data; } @@ -72,6 +75,7 @@ protected override void Dispose(bool disposing) { outputObserver.Dispose(); + inputObserver.Dispose(); if (disposing) { Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsOutputViewTest.cs =================================================================== diff -u -r187efa574b622ec8fd7d3f82f367974e17dbf138 -r8a563ecfb400fafa392d2b849c597a99e3acac8c --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsOutputViewTest.cs (.../MacroStabilityInwardsOutputViewTest.cs) (revision 187efa574b622ec8fd7d3f82f367974e17dbf138) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsOutputViewTest.cs (.../MacroStabilityInwardsOutputViewTest.cs) (revision 8a563ecfb400fafa392d2b849c597a99e3acac8c) @@ -221,6 +221,87 @@ } } + [Test] + public void GivenViewWithOutputSet_WhenInputChangedAndObserversNotified_ThenChartDataUpdated() + { + // Given + using (var form = new Form()) + using (var view = new MacroStabilityInwardsOutputView()) + { + form.Controls.Add(view); + form.Show(); + + MacroStabilityInwardsOutputChartControl chartControl = GetChartControl(form); + + MacroStabilityInwardsSurfaceLine surfaceLine = GetSurfaceLineWithGeometry(); + MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = GetStochasticSoilProfile2D(); + var calculation = new MacroStabilityInwardsCalculationScenario + { + InputParameters = + { + SurfaceLine = surfaceLine, + StochasticSoilProfile = stochasticSoilProfile + }, + Output = MacroStabilityInwardsOutputTestFactory.CreateOutput() + }; + + view.Data = calculation; + + ChartDataCollection chartData = GetChartControl(chartControl).Data; + + // Precondition + MacroStabilityInwardsOutputViewChartDataAssert.AssertChartData(calculation, chartData); + + // When + MacroStabilityInwardsStochasticSoilProfile newSoilProfile = GetStochasticSoilProfile2D(); + calculation.InputParameters.StochasticSoilProfile = newSoilProfile; + calculation.InputParameters.NotifyObservers(); + + // Then + MacroStabilityInwardsOutputViewChartDataAssert.AssertChartData(calculation, chartData); + } + } + + [Test] + public void GivenViewWithoutOutputSet_WhenInputChangedAndObserversNotified_ThenChartDataUpdated() + { + // Given + using (var form = new Form()) + using (var view = new MacroStabilityInwardsOutputView()) + { + form.Controls.Add(view); + form.Show(); + + MacroStabilityInwardsOutputChartControl chartControl = GetChartControl(form); + + MacroStabilityInwardsSurfaceLine surfaceLine = GetSurfaceLineWithGeometry(); + MacroStabilityInwardsStochasticSoilProfile stochasticSoilProfile = GetStochasticSoilProfile2D(); + var calculation = new MacroStabilityInwardsCalculationScenario + { + InputParameters = + { + SurfaceLine = surfaceLine, + StochasticSoilProfile = stochasticSoilProfile + } + }; + + view.Data = calculation; + + ChartDataCollection chartData = GetChartControl(chartControl).Data; + + // Precondition + MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyChartDataWithEmptySoilLayerAndEmptyWaternetChartData(chartData); + + // When + MacroStabilityInwardsStochasticSoilProfile newSoilProfile = GetStochasticSoilProfile2D(); + calculation.InputParameters.StochasticSoilProfile = newSoilProfile; + calculation.InputParameters.NotifyObservers(); + + // Then + MacroStabilityInwardsOutputViewChartDataAssert.AssertEmptyChartDataWithEmptySoilLayerAndEmptyWaternetChartData(chartData); + } + } + private static MacroStabilityInwardsOutputChartControl GetChartControl(Form form) { return ControlTestHelper.GetControls(form, "macroStabilityInwardsOutputChartControl").Single();