Index: Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoAssessmentSectionCommand.cs =================================================================== diff -u -rc5f90c4f9b42d985f16f99ad8732576b9217267a -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoAssessmentSectionCommand.cs (.../AddNewDemoAssessmentSectionCommand.cs) (revision c5f90c4f9b42d985f16f99ad8732576b9217267a) +++ Demo/Ringtoets/src/Demo.Ringtoets/Commands/AddNewDemoAssessmentSectionCommand.cs (.../AddNewDemoAssessmentSectionCommand.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -129,6 +129,9 @@ StandardDeviation = originalPhreaticLevelExit.StandardDeviation }; calculation.InputParameters.SurfaceLine = pipingFailureMechanism.SurfaceLines.First(sl => sl.Name == "PK001_0001"); + + pipingFailureMechanism.CalculationsGroup.AddCalculationScenariosToFailureMechanismSectionResult(pipingFailureMechanism); + var stochasticSoilModel = pipingFailureMechanism.StochasticSoilModels.First(sm => sm.Name == "PK001_0001_Piping"); calculation.InputParameters.StochasticSoilModel = stochasticSoilModel; calculation.InputParameters.StochasticSoilProfile = stochasticSoilModel.StochasticSoilProfiles.First(sp => sp.SoilProfile.Name == "W1-6_0_1D1"); Index: Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs =================================================================== diff -u -rd148009f276fb1d4a7a4cbacb730c31114b7e4ae -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs (.../AddNewDemoAssessmentSectionCommandTest.cs) (revision d148009f276fb1d4a7a4cbacb730c31114b7e4ae) +++ Demo/Ringtoets/test/Demo.Ringtoets.Test/Commands/AddNewDemoAssessmentSectionCommandTest.cs (.../AddNewDemoAssessmentSectionCommandTest.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -1,4 +1,5 @@ using System; +using System.Collections.Generic; using System.IO; using System.Linq; using Core.Common.Base; @@ -10,6 +11,7 @@ using NUnit.Framework; using Rhino.Mocks; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Probabilistics; using Ringtoets.HydraRing.Data; using Ringtoets.Integration.Data; @@ -85,6 +87,7 @@ Assert.AreEqual(1, demoAssessmentSection.PipingFailureMechanism.CalculationsGroup.Children.Count); var calculation = demoAssessmentSection.PipingFailureMechanism.CalculationsGroup.GetCalculations().OfType().First(); AssertCalculationAbleToCalculate(calculation); + AssertCalculationInFailureMechanismSectionResult(calculation, demoAssessmentSection.PipingFailureMechanism.SectionResults.ToArray()); foreach (var failureMechanism in demoAssessmentSection.GetFailureMechanisms()) { @@ -93,6 +96,14 @@ mocks.VerifyAll(); } + private void AssertCalculationInFailureMechanismSectionResult(PipingCalculationScenario calculation, FailureMechanismSectionResult[] sectionResults) + { + Assert.AreEqual(283, sectionResults.Length); + var sectionResultWithCalculation = sectionResults[22]; + + CollectionAssert.AreEqual(new[] { calculation }, sectionResultWithCalculation.CalculationScenarios); + } + private void AssertValuesOnHydraulicBoundaryLocations(HydraulicBoundaryLocation[] hydraulicBoundaryLocations) { Assert.AreEqual(5.78, hydraulicBoundaryLocations[0].DesignWaterLevel); Index: Ringtoets/Common/src/Ringtoets.Common.Data/Calculation/ICalculation.cs =================================================================== diff -u -r6b43c39e0f54d1054729aaed5aa6dc19149ef72a -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Common/src/Ringtoets.Common.Data/Calculation/ICalculation.cs (.../ICalculation.cs) (revision 6b43c39e0f54d1054729aaed5aa6dc19149ef72a) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Calculation/ICalculation.cs (.../ICalculation.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -52,5 +52,10 @@ /// Gets the input of the calculation to observe. /// ICalculationInput GetObservableInput(); + + /// + /// Gets the output of the calculation to observe. + /// + ICalculationOutput GetObservableOutput(); } } \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/Calculation/ICalculationOutput.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Data/Calculation/ICalculationOutput.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Calculation/ICalculationOutput.cs (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -0,0 +1,30 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using Core.Common.Base; + +namespace Ringtoets.Common.Data.Calculation +{ + /// + /// Interface describing an object that is the output to a . + /// + public interface ICalculationOutput : IObservable { } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj =================================================================== diff -u -rd148009f276fb1d4a7a4cbacb730c31114b7e4ae -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision d148009f276fb1d4a7a4cbacb730c31114b7e4ae) +++ Ringtoets/Common/src/Ringtoets.Common.Data/Ringtoets.Common.Data.csproj (.../Ringtoets.Common.Data.csproj) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -45,6 +45,7 @@ + Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs =================================================================== diff -u -r89cf0d104a6e12180d2fae471ae318cad256707a -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 89cf0d104a6e12180d2fae471ae318cad256707a) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -470,7 +470,7 @@ } /// - /// Looks up a localized string similar to Bijdrage van de geselecteerde scenario's voor dit vak zijn opgeteld niet gelijk aan 100%.. + /// Looks up a localized string similar to Bijdrage van de geselecteerde scenario's voor dit vak is opgeteld niet gelijk aan 100%.. /// public static string FailureMechanismResultView_DataGridViewCellFormatting_Scenario_contribution_for_this_section_not_100 { get { Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx =================================================================== diff -u -r89cf0d104a6e12180d2fae471ae318cad256707a -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision 89cf0d104a6e12180d2fae471ae318cad256707a) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Properties/Resources.resx (.../Resources.resx) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -257,7 +257,7 @@ ..\Resources\document-task.png;System.Drawing.Bitmap, System.Drawing, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a - Bijdrage van de geselecteerde scenario's voor dit vak zijn opgeteld niet gelijk aan 100%. + Bijdrage van de geselecteerde scenario's voor dit vak is opgeteld niet gelijk aan 100%. Niet alle berekeningen voor dit vak zijn uitgevoerd. Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs =================================================================== diff -u -ra1bdc4941a7918bf20b1ea7247a725aa568a2b68 -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision a1bdc4941a7918bf20b1ea7247a725aa568a2b68) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismResultView.cs (.../FailureMechanismResultView.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -44,6 +44,7 @@ private readonly Observer failureMechanismObserver; private readonly RecursiveObserver failureMechanismSectionResultObserver; private readonly RecursiveObserver calculationInputObserver; + private readonly RecursiveObserver calculationOutputObserver; private readonly RecursiveObserver calculationGroupObserver; private IEnumerable failureMechanismSectionResult; @@ -64,6 +65,7 @@ failureMechanismSectionResultObserver = new RecursiveObserver(RefreshDataGridView, mechanism => mechanism.SectionResults); // The concat is needed to observe the input of calculations in child groups. calculationInputObserver = new RecursiveObserver(UpdataDataGridViewDataSource, cg => cg.Children.Concat(cg.Children.OfType().Select(c => c.GetObservableInput()))); + calculationOutputObserver = new RecursiveObserver(UpdataDataGridViewDataSource, cg => cg.Children.Concat(cg.Children.OfType().Select(c => c.GetObservableOutput()))); calculationGroupObserver = new RecursiveObserver(UpdataDataGridViewDataSource, c => c.Children); Load += OnLoad; } @@ -88,6 +90,7 @@ CalculationGroup observableGroup = calculatableFailureMechanism != null ? calculatableFailureMechanism.CalculationsGroup : null; calculationInputObserver.Observable = observableGroup; + calculationOutputObserver.Observable = observableGroup; calculationGroupObserver.Observable = observableGroup; } } @@ -120,6 +123,7 @@ failureMechanismObserver.Dispose(); failureMechanismSectionResultObserver.Dispose(); calculationInputObserver.Dispose(); + calculationOutputObserver.Dispose(); calculationGroupObserver.Dispose(); if (disposing && (components != null)) Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs =================================================================== diff -u -r36b6f1f7c1ddf585689512eb61256d41a1e0ca64 -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs (.../RingtoetsContextMenuItemFactoryTest.cs) (revision 36b6f1f7c1ddf585689512eb61256d41a1e0ca64) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsContextMenuItemFactoryTest.cs (.../RingtoetsContextMenuItemFactoryTest.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -673,6 +673,11 @@ { return null; } + + public ICalculationOutput GetObservableOutput() + { + return null; + } } # endregion Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsTreeNodeInfoFactoryTest.cs =================================================================== diff -u -r36b6f1f7c1ddf585689512eb61256d41a1e0ca64 -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsTreeNodeInfoFactoryTest.cs (.../RingtoetsTreeNodeInfoFactoryTest.cs) (revision 36b6f1f7c1ddf585689512eb61256d41a1e0ca64) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TreeNodeInfos/RingtoetsTreeNodeInfoFactoryTest.cs (.../RingtoetsTreeNodeInfoFactoryTest.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -1111,6 +1111,11 @@ { return null; } + + public ICalculationOutput GetObservableOutput() + { + return null; + } } private class TestFailureMechanismContext : FailureMechanismContext Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/FailureMechanismResultViewTest.cs =================================================================== diff -u -rf5e1194ee412e86277cee388a75c39db189f2b3e -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/FailureMechanismResultViewTest.cs (.../FailureMechanismResultViewTest.cs) (revision f5e1194ee412e86277cee388a75c39db189f2b3e) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/FailureMechanismResultViewTest.cs (.../FailureMechanismResultViewTest.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -369,7 +369,7 @@ var formattedValue = dataGridViewCell.FormattedValue; // Need to do this to fire the CellFormatting event. // Assert - Assert.AreEqual("Bijdrage van de geselecteerde scenario's voor dit vak zijn opgeteld niet gelijk aan 100%.", dataGridViewCell.ErrorText); + Assert.AreEqual("Bijdrage van de geselecteerde scenario's voor dit vak is opgeteld niet gelijk aan 100%.", dataGridViewCell.ErrorText); Assert.AreEqual(double.NaN.ToString(CultureInfo.InvariantCulture), formattedValue); mocks.VerifyAll(); } Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsCalculation.cs =================================================================== diff -u -rdec46d5efaad5332ffb2a96e67ec11209ddc5515 -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsCalculation.cs (.../GrassCoverErosionInwardsCalculation.cs) (revision dec46d5efaad5332ffb2a96e67ec11209ddc5515) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsCalculation.cs (.../GrassCoverErosionInwardsCalculation.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -88,6 +88,11 @@ return InputParameters; } + public ICalculationOutput GetObservableOutput() + { + return Output; + } + private void AddDemoInput() { // BreakWater Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsOutput.cs =================================================================== diff -u -rc76403f10e7eaa78da898922b3955851786b855f -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsOutput.cs (.../GrassCoverErosionInwardsOutput.cs) (revision c76403f10e7eaa78da898922b3955851786b855f) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Data/GrassCoverErosionInwardsOutput.cs (.../GrassCoverErosionInwardsOutput.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -19,14 +19,16 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using Core.Common.Base; using Core.Common.Base.Data; +using Ringtoets.Common.Data.Calculation; namespace Ringtoets.GrassCoverErosionInwards.Data { /// /// This class contains the results of a grass cover erosion inwards calculation. /// - public class GrassCoverErosionInwardsOutput + public class GrassCoverErosionInwardsOutput : Observable, ICalculationOutput { private RoundedDouble probability; private RoundedDouble reliability; Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsCalculationTest.cs =================================================================== diff -u -r392c4a63ebfaee062d8dc611ecf41881ac1fe3a5 -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsCalculationTest.cs (.../GrassCoverErosionInwardsCalculationTest.cs) (revision 392c4a63ebfaee062d8dc611ecf41881ac1fe3a5) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsCalculationTest.cs (.../GrassCoverErosionInwardsCalculationTest.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -173,9 +173,26 @@ ICalculationInput input = calculation.GetObservableInput(); // Assert - Assert.AreEqual(inputParameters, input); + Assert.AreSame(inputParameters, input); } + [Test] + public void GetObservalbeOutput_Always_ReturnsOutput() + { + // Setup + var output = new GrassCoverErosionInwardsOutput(2.0, 3.0, 1.4, 50.3, 16.3); + var calculation = new GrassCoverErosionInwardsCalculation(new GeneralGrassCoverErosionInwardsInput()) + { + Output = output + }; + + // Call + ICalculationOutput calculationOutput = calculation.GetObservableOutput(); + + // Assert + Assert.AreSame(output, calculationOutput); + } + private void AssertDemoInput(GrassCoverErosionInwardsInput inputParameters) { // BreakWater Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsOutputTest.cs =================================================================== diff -u -rdec46d5efaad5332ffb2a96e67ec11209ddc5515 -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsOutputTest.cs (.../GrassCoverErosionInwardsOutputTest.cs) (revision dec46d5efaad5332ffb2a96e67ec11209ddc5515) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Data.Test/GrassCoverErosionInwardsOutputTest.cs (.../GrassCoverErosionInwardsOutputTest.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -20,8 +20,10 @@ // All rights reserved. using System; +using Core.Common.Base; using Core.Common.Base.Data; using NUnit.Framework; +using Ringtoets.Common.Data.Calculation; namespace Ringtoets.GrassCoverErosionInwards.Data.Test { @@ -43,6 +45,8 @@ var output = new GrassCoverErosionInwardsOutput(requiredProbability, requiredReliability, probability, reliability, factorOfSafety); // Assert + Assert.IsInstanceOf(output); + Assert.IsInstanceOf(output); Assert.IsNotNull(output); Assert.AreEqual(requiredProbability, output.RequiredProbability); Assert.AreEqual(requiredReliability, output.RequiredReliability); Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingCalculation.cs =================================================================== diff -u -rfff12e249602fb700b2854c14a3b7cdd0b73c023 -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingCalculation.cs (.../PipingCalculation.cs) (revision fff12e249602fb700b2854c14a3b7cdd0b73c023) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingCalculation.cs (.../PipingCalculation.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -102,5 +102,10 @@ { return InputParameters; } + + public ICalculationOutput GetObservableOutput() + { + return Output; + } } } \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingCalculationGroupExtensions.cs =================================================================== diff -u -r34a892d5a6359899794f3fb44fcc5a900abaf697 -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingCalculationGroupExtensions.cs (.../PipingCalculationGroupExtensions.cs) (revision 34a892d5a6359899794f3fb44fcc5a900abaf697) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingCalculationGroupExtensions.cs (.../PipingCalculationGroupExtensions.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -21,7 +21,6 @@ using System.Linq; using Core.Common.Base.Geometry; -using Ringtoets.Common.Data; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Data.FailureMechanism; Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingCalculationScenario.cs =================================================================== diff -u -rcb52c5ede0d946ce4ea1c704dc2231fba080b402 -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingCalculationScenario.cs (.../PipingCalculationScenario.cs) (revision cb52c5ede0d946ce4ea1c704dc2231fba080b402) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingCalculationScenario.cs (.../PipingCalculationScenario.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -66,7 +66,7 @@ { get { - if (SemiProbabilisticOutput == null) + if (!HasOutput) { return CalculationScenarioStatus.NotCalculated; } Index: Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingOutput.cs =================================================================== diff -u -r4512af7782ee31b36941bb280b54d9da2953dd71 -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingOutput.cs (.../PipingOutput.cs) (revision 4512af7782ee31b36941bb280b54d9da2953dd71) +++ Ringtoets/Piping/src/Ringtoets.Piping.Data/PipingOutput.cs (.../PipingOutput.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -19,12 +19,15 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using Core.Common.Base; +using Ringtoets.Common.Data.Calculation; + namespace Ringtoets.Piping.Data { /// /// Simple class containing the results of a Piping calculation. /// - public class PipingOutput + public class PipingOutput : Observable, ICalculationOutput { /// /// Creates a new instance of . Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingCalculationScenarioTest.cs =================================================================== diff -u -r23a37b025a5d0358c1f30fb31de41a2c284519a5 -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingCalculationScenarioTest.cs (.../PipingCalculationScenarioTest.cs) (revision 23a37b025a5d0358c1f30fb31de41a2c284519a5) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingCalculationScenarioTest.cs (.../PipingCalculationScenarioTest.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -23,6 +23,7 @@ using Core.Common.Base.Data; using NUnit.Framework; using Ringtoets.Common.Data.Calculation; +using Ringtoets.Piping.KernelWrapper.TestUtil; namespace Ringtoets.Piping.Data.Test { @@ -94,9 +95,12 @@ var generalInputParameters = new GeneralPipingInput(); var semiProbabilisticInputParameters = new NormProbabilityPipingInput(); - var scenario = new PipingCalculationScenario(generalInputParameters, semiProbabilisticInputParameters); - scenario.SemiProbabilisticOutput = new PipingSemiProbabilisticOutput(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, expectedProbability, 0, 0); - + var scenario = new PipingCalculationScenario(generalInputParameters, semiProbabilisticInputParameters) + { + Output = new TestPipingOutput(), + SemiProbabilisticOutput = new PipingSemiProbabilisticOutput(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, expectedProbability, 0, 0) + }; + // Call RoundedDouble probability = scenario.Probability; @@ -146,6 +150,7 @@ var scenario = new PipingCalculationScenario(generalInputParameters, semiProbabilisticInputParameters) { + Output = new TestPipingOutput(), SemiProbabilisticOutput = new PipingSemiProbabilisticOutput(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, double.NaN, 0, 0) }; @@ -165,8 +170,11 @@ var generalInputParameters = new GeneralPipingInput(); var semiProbabilisticInputParameters = new NormProbabilityPipingInput(); - var scenario = new PipingCalculationScenario(generalInputParameters, semiProbabilisticInputParameters); - scenario.SemiProbabilisticOutput = new PipingSemiProbabilisticOutput(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, expectedProbability, 0, 0); + var scenario = new PipingCalculationScenario(generalInputParameters, semiProbabilisticInputParameters) + { + Output = new TestPipingOutput(), + SemiProbabilisticOutput = new PipingSemiProbabilisticOutput(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, expectedProbability, 0, 0) + }; // Call CalculationScenarioStatus status = scenario.CalculationScenarioStatus; Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingCalculationTest.cs =================================================================== diff -u -rc76403f10e7eaa78da898922b3955851786b855f -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingCalculationTest.cs (.../PipingCalculationTest.cs) (revision c76403f10e7eaa78da898922b3955851786b855f) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingCalculationTest.cs (.../PipingCalculationTest.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -264,7 +264,24 @@ ICalculationInput input = calculation.GetObservableInput(); // Assert - Assert.AreEqual(inputParameters, input); + Assert.AreSame(inputParameters, input); } + + [Test] + public void GetObservalbeOutput_Always_ReturnsOutput() + { + // Setup + var output = new PipingOutput(2.0, 3.0, 1.4, 50.3, 16.3, 58.2); + var calculation = new PipingCalculation(new GeneralPipingInput(), new NormProbabilityPipingInput()) + { + Output = output + }; + + // Call + ICalculationOutput calculationOutput = calculation.GetObservableOutput(); + + // Assert + Assert.AreSame(output, calculationOutput); + } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingOutputTest.cs =================================================================== diff -u -rc7c07db38829afdc5965c331844e1d39123944ff -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingOutputTest.cs (.../PipingOutputTest.cs) (revision c7c07db38829afdc5965c331844e1d39123944ff) +++ Ringtoets/Piping/test/Ringtoets.Piping.Data.Test/PipingOutputTest.cs (.../PipingOutputTest.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -20,14 +20,16 @@ // All rights reserved. using System; +using Core.Common.Base; using NUnit.Framework; +using Ringtoets.Common.Data.Calculation; namespace Ringtoets.Piping.Data.Test { public class PipingOutputTest { [Test] - public void GivenSomeValues_WhenConstructedWithValues_ThenPropertiesAreSet() + public void Constructor_ExpectedValues() { var random = new Random(22); var zuValue = random.NextDouble(); @@ -37,14 +39,16 @@ var zsValue = random.NextDouble(); var foSsValue = random.NextDouble(); - var actual = new PipingOutput(zuValue, foSuValue, zhValue, foShValue, zsValue, foSsValue); + var output = new PipingOutput(zuValue, foSuValue, zhValue, foShValue, zsValue, foSsValue); - Assert.That(actual.UpliftZValue, Is.EqualTo(zuValue)); - Assert.That(actual.UpliftFactorOfSafety, Is.EqualTo(foSuValue)); - Assert.That(actual.HeaveZValue, Is.EqualTo(zhValue)); - Assert.That(actual.HeaveFactorOfSafety, Is.EqualTo(foShValue)); - Assert.That(actual.SellmeijerZValue, Is.EqualTo(zsValue)); - Assert.That(actual.SellmeijerFactorOfSafety, Is.EqualTo(foSsValue)); + Assert.IsInstanceOf(output); + Assert.IsInstanceOf(output); + Assert.AreEqual(output.UpliftZValue, zuValue); + Assert.AreEqual(output.UpliftFactorOfSafety, foSuValue); + Assert.AreEqual(output.HeaveZValue, zhValue); + Assert.AreEqual(output.HeaveFactorOfSafety, foShValue); + Assert.AreEqual(output.SellmeijerZValue, zsValue); + Assert.AreEqual(output.SellmeijerFactorOfSafety, foSsValue); } } } \ No newline at end of file Index: Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/FailureMechanismResultViewIntegrationTest.cs =================================================================== diff -u -rb1c2f3f896147de67d46fde3bce9098d94054037 -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/FailureMechanismResultViewIntegrationTest.cs (.../FailureMechanismResultViewIntegrationTest.cs) (revision b1c2f3f896147de67d46fde3bce9098d94054037) +++ Ringtoets/Piping/test/Ringtoets.Piping.Integration.Test/FailureMechanismResultViewIntegrationTest.cs (.../FailureMechanismResultViewIntegrationTest.cs) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -81,7 +81,7 @@ } }; - // Add a piping calculation and ensure it is shown in the data grid view; + // Add a piping calculation and ensure it is shown in the data grid view assessmentSection.PipingFailureMechanism.CalculationsGroup.Children.Add(pipingCalculation1); assessmentSection.PipingFailureMechanism.CalculationsGroup.NotifyObservers(); assessmentSection.PipingFailureMechanism.CalculationsGroup.AddCalculationScenariosToFailureMechanismSectionResult(assessmentSection.PipingFailureMechanism); @@ -100,7 +100,7 @@ nestedPipingCalculationGroup.NotifyObservers(); assessmentSection.PipingFailureMechanism.CalculationsGroup.AddCalculationScenariosToFailureMechanismSectionResult(assessmentSection.PipingFailureMechanism); Assert.AreEqual(double.NaN.ToString(CultureInfo.InvariantCulture), dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].FormattedValue); - Assert.AreEqual("Bijdrage van de geselecteerde scenario's voor dit vak zijn opgeteld niet gelijk aan 100%.", dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].ErrorText); + Assert.AreEqual("Bijdrage van de geselecteerde scenario's voor dit vak is opgeteld niet gelijk aan 100%.", dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].ErrorText); // Set the second calculation to not relevant and ensure the data grid view is updated pipingCalculation2.IsRelevant = false; @@ -110,12 +110,13 @@ // Execute the first calculation and ensure the data grid view is updated const double probability = 31846382; + pipingCalculation1.Output = new PipingOutput(0, 0, 0, 0, 0, 0); pipingCalculation1.SemiProbabilisticOutput = new PipingSemiProbabilisticOutput(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, probability, 0, 0); pipingCalculation1.NotifyObservers(); Assert.AreEqual(string.Format("1/{0:N0}", pipingCalculation1.Probability), dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].FormattedValue); Assert.AreEqual(string.Empty, dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].ErrorText); - // Add another, nested calculation without surface line and ensure the data grid view is updated when the surface line is set. + // Add another, nested calculation without surface line and ensure the data grid view is updated when the surface line is set var pipingCalculation3 = new PipingCalculationScenario(new GeneralPipingInput(), new NormProbabilityPipingInput()); nestedPipingCalculationGroup.Children.Add(pipingCalculation3); nestedPipingCalculationGroup.NotifyObservers(); @@ -127,18 +128,37 @@ PipingCalculationScenarioService.SyncCalculationScenarioWithNewSurfaceLine(pipingCalculation3, assessmentSection.PipingFailureMechanism, null); pipingCalculation3.InputParameters.NotifyObservers(); Assert.AreEqual(double.NaN.ToString(CultureInfo.InvariantCulture), dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].FormattedValue); - Assert.AreEqual("Bijdrage van de geselecteerde scenario's voor dit vak zijn opgeteld niet gelijk aan 100%.", dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].ErrorText); + Assert.AreEqual("Bijdrage van de geselecteerde scenario's voor dit vak is opgeteld niet gelijk aan 100%.", dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].ErrorText); // Change the contribution of the calculation and make sure the data grid view is updated pipingCalculation3.Contribution = (RoundedDouble) 0.3; pipingCalculation3.NotifyObservers(); Assert.AreEqual(double.NaN.ToString(CultureInfo.InvariantCulture), dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].FormattedValue); - Assert.AreEqual("Bijdrage van de geselecteerde scenario's voor dit vak zijn opgeteld niet gelijk aan 100%.", dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].ErrorText); + Assert.AreEqual("Bijdrage van de geselecteerde scenario's voor dit vak is opgeteld niet gelijk aan 100%.", dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].ErrorText); pipingCalculation1.Contribution = (RoundedDouble) 0.7; pipingCalculation1.NotifyObservers(); Assert.AreEqual("-", dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].FormattedValue); Assert.AreEqual("Niet alle berekeningen voor dit vak zijn uitgevoerd.", dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].ErrorText); + + // Remove a calculation and make sure the data grid view is updated + nestedPipingCalculationGroup.Children.Remove(pipingCalculation3); + PipingCalculationScenarioService.RemoveCalculationScenarioFromSectionResult(pipingCalculation3, assessmentSection.PipingFailureMechanism); + nestedPipingCalculationGroup.NotifyObservers(); + Assert.AreEqual(double.NaN.ToString(CultureInfo.InvariantCulture), dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].FormattedValue); + Assert.AreEqual("Bijdrage van de geselecteerde scenario's voor dit vak is opgeteld niet gelijk aan 100%.", dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].ErrorText); + + // Set contribution again so we have a probability. + pipingCalculation1.Contribution = (RoundedDouble) 1.0; + pipingCalculation1.NotifyObservers(); + Assert.AreEqual(string.Format("1/{0:N0}", pipingCalculation1.Probability), dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].FormattedValue); + Assert.AreEqual(string.Empty, dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].ErrorText); + + // Clear the output of the calculation and make sure the data grid view is updated + pipingCalculation1.ClearOutput(); + pipingCalculation1.NotifyObservers(); + Assert.AreEqual("-", dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].FormattedValue); + Assert.AreEqual("Niet alle berekeningen voor dit vak zijn uitgevoerd.", dataGridView.Rows[22].Cells[assessmentLayerTwoAIndex].ErrorText); } } Index: Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil/Ringtoets.Piping.KernelWrapper.TestUtil.csproj =================================================================== diff -u -r238411e28abf2f71dc0a5715ca940c6e87df9392 -r0a94ed42cb943659d68be2ce6fb430f8f29fc3f3 --- Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil/Ringtoets.Piping.KernelWrapper.TestUtil.csproj (.../Ringtoets.Piping.KernelWrapper.TestUtil.csproj) (revision 238411e28abf2f71dc0a5715ca940c6e87df9392) +++ Ringtoets/Piping/test/Ringtoets.Piping.KernelWrapper.TestUtil/Ringtoets.Piping.KernelWrapper.TestUtil.csproj (.../Ringtoets.Piping.KernelWrapper.TestUtil.csproj) (revision 0a94ed42cb943659d68be2ce6fb430f8f29fc3f3) @@ -67,6 +67,10 @@ {3bbfd65b-b277-4e50-ae6d-bd24c3434609} Core.Common.Base + + {d4200f43-3f72-4f42-af0a-8ced416a38ec} + Ringtoets.Common.Data + {ce994cc9-6f6a-48ac-b4be-02c30a21f4db} Ringtoets.Piping.Data