Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismSectionResultRow.cs =================================================================== diff -u -r4d2271ee60b40225ccfeb4a8eadc40c7e0fae357 -r028fa7ac2f1cc6bec17d9db071064febd4f6261b --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismSectionResultRow.cs (.../HeightStructuresFailureMechanismSectionResultRow.cs) (revision 4d2271ee60b40225ccfeb4a8eadc40c7e0fae357) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismSectionResultRow.cs (.../HeightStructuresFailureMechanismSectionResultRow.cs) (revision 028fa7ac2f1cc6bec17d9db071064febd4f6261b) @@ -37,6 +37,7 @@ /// Creates a new instance of . /// /// The this row contains. + /// Thrown when is null. public HeightStructuresFailureMechanismSectionResultRow(HeightStructuresFailureMechanismSectionResult sectionResult) { if (sectionResult == null) Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj =================================================================== diff -u -r8ed27cd893d87ef66f1bc4f6936407dcff4a284c -r028fa7ac2f1cc6bec17d9db071064febd4f6261b --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision 8ed27cd893d87ef66f1bc4f6936407dcff4a284c) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Ringtoets.Piping.Forms.csproj (.../Ringtoets.Piping.Forms.csproj) (revision 028fa7ac2f1cc6bec17d9db071064febd4f6261b) @@ -93,6 +93,7 @@ + UserControl Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationRow.cs =================================================================== diff -u --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationRow.cs (revision 0) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationRow.cs (revision 028fa7ac2f1cc6bec17d9db071064febd4f6261b) @@ -0,0 +1,250 @@ +// 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 System; +using System.Globalization; +using Core.Common.Base.Data; +using Core.Common.Controls.DataGrid; +using Ringtoets.HydraRing.Data; +using Ringtoets.Piping.Data; + +namespace Ringtoets.Piping.Forms.Views +{ + /// + /// This class represents a row of . + /// + internal class PipingCalculationRow + { + private readonly PipingCalculationScenario pipingCalculation; + + /// + /// Creates a new instance of . + /// + /// The this row contains. + /// Thrown when is null. + public PipingCalculationRow(PipingCalculationScenario pipingCalculation) + { + if (pipingCalculation == null) + { + throw new ArgumentNullException("pipingCalculation"); + } + + this.pipingCalculation = pipingCalculation; + } + + /// + /// Gets the this row contains. + /// + public PipingCalculationScenario PipingCalculation + { + get + { + return pipingCalculation; + } + } + + /// + /// Gets and sets the is relevant. + /// + public bool IsRelevant + { + get + { + return pipingCalculation.IsRelevant; + } + set + { + pipingCalculation.IsRelevant = value; + pipingCalculation.NotifyObservers(); + } + } + + /// + /// Gets and sets the contribution of the . + /// + public RoundedDouble Contribution + { + get + { + return new RoundedDouble(0, pipingCalculation.Contribution * 100); + } + set + { + pipingCalculation.Contribution = new RoundedDouble(2, value / 100); + pipingCalculation.NotifyObservers(); + } + } + + /// + /// Gets and sets the name of the . + /// + public string Name + { + get + { + return pipingCalculation.Name; + } + set + { + pipingCalculation.Name = value; + + pipingCalculation.NotifyObservers(); + } + } + + /// + /// Gets and sets the stochastic soil model of the . + /// + public DataGridViewComboBoxItemWrapper StochasticSoilModel + { + get + { + return new DataGridViewComboBoxItemWrapper(pipingCalculation.InputParameters.StochasticSoilModel); + } + set + { + pipingCalculation.InputParameters.StochasticSoilModel = value != null + ? value.WrappedObject + : null; + pipingCalculation.InputParameters.NotifyObservers(); + } + } + + /// + /// Gets and sets the stochastic soil profile of the . + /// + public DataGridViewComboBoxItemWrapper StochasticSoilProfile + { + get + { + return new DataGridViewComboBoxItemWrapper(pipingCalculation.InputParameters.StochasticSoilProfile); + } + set + { + pipingCalculation.InputParameters.StochasticSoilProfile = value != null + ? value.WrappedObject + : null; + + pipingCalculation.InputParameters.NotifyObservers(); + } + } + + /// + /// Gets the stochastic soil profile probability of the . + /// + public string StochasticSoilProfileProbability + { + get + { + return pipingCalculation.InputParameters.StochasticSoilProfile != null + ? new RoundedDouble(3, pipingCalculation.InputParameters.StochasticSoilProfile.Probability * 100).Value.ToString(CultureInfo.CurrentCulture) + : new RoundedDouble(3).Value.ToString(CultureInfo.CurrentCulture); + } + } + + /// + /// Gets and sets the hydraulic boundary location of the . + /// + public DataGridViewComboBoxItemWrapper HydraulicBoundaryLocation + { + get + { + return new DataGridViewComboBoxItemWrapper(pipingCalculation.InputParameters.HydraulicBoundaryLocation); + } + set + { + pipingCalculation.InputParameters.HydraulicBoundaryLocation = value != null + ? value.WrappedObject + : null; + + pipingCalculation.InputParameters.NotifyObservers(); + } + } + + /// + /// Gets and sets the damping factory exit mean of the . + /// + public RoundedDouble DampingFactorExitMean + { + get + { + return pipingCalculation.InputParameters.DampingFactorExit.Mean; + } + set + { + pipingCalculation.InputParameters.DampingFactorExit.Mean = value; + + pipingCalculation.InputParameters.NotifyObservers(); + } + } + + /// + /// Gets and sets the phreatic level exit mean of the . + /// + public RoundedDouble PhreaticLevelExitMean + { + get + { + return pipingCalculation.InputParameters.PhreaticLevelExit.Mean; + } + set + { + pipingCalculation.InputParameters.PhreaticLevelExit.Mean = value; + + pipingCalculation.InputParameters.NotifyObservers(); + } + } + + /// + /// Gets and sets the entry point l of the . + /// + public RoundedDouble EntryPointL + { + get + { + return pipingCalculation.InputParameters.EntryPointL; + } + set + { + pipingCalculation.InputParameters.EntryPointL = value; + + pipingCalculation.InputParameters.NotifyObservers(); + } + } + + /// + /// Gets and sets the exit point l of the . + /// + public RoundedDouble ExitPointL + { + get + { + return pipingCalculation.InputParameters.ExitPointL; + } + set + { + pipingCalculation.InputParameters.ExitPointL = value; + + pipingCalculation.InputParameters.NotifyObservers(); + } + } + } +} \ No newline at end of file Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs =================================================================== diff -u -rd48d2c62b4a2d2f177e1725e1b84e54a8d49327f -r028fa7ac2f1cc6bec17d9db071064febd4f6261b --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision d48d2c62b4a2d2f177e1725e1b84e54a8d49327f) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingCalculationsView.cs (.../PipingCalculationsView.cs) (revision 028fa7ac2f1cc6bec17d9db071064febd4f6261b) @@ -485,177 +485,6 @@ } } - private class PipingCalculationRow - { - private readonly PipingCalculationScenario pipingCalculation; - - public PipingCalculationRow(PipingCalculationScenario pipingCalculation) - { - this.pipingCalculation = pipingCalculation; - } - - public PipingCalculationScenario PipingCalculation - { - get - { - return pipingCalculation; - } - } - - public bool IsRelevant - { - get - { - return pipingCalculation.IsRelevant; - } - set - { - pipingCalculation.IsRelevant = value; - pipingCalculation.NotifyObservers(); - } - } - - public RoundedDouble Contribution - { - get - { - return new RoundedDouble(0, pipingCalculation.Contribution*100); - } - set - { - pipingCalculation.Contribution = new RoundedDouble(2, value/100); - pipingCalculation.NotifyObservers(); - } - } - - public string Name - { - get - { - return pipingCalculation.Name; - } - set - { - pipingCalculation.Name = value; - - pipingCalculation.NotifyObservers(); - } - } - - public DataGridViewComboBoxItemWrapper StochasticSoilModel - { - get - { - return new DataGridViewComboBoxItemWrapper(pipingCalculation.InputParameters.StochasticSoilModel); - } - set - { - pipingCalculation.InputParameters.StochasticSoilModel = value != null - ? value.WrappedObject - : null; - pipingCalculation.InputParameters.NotifyObservers(); - } - } - - public DataGridViewComboBoxItemWrapper StochasticSoilProfile - { - get - { - return new DataGridViewComboBoxItemWrapper(pipingCalculation.InputParameters.StochasticSoilProfile); - } - set - { - pipingCalculation.InputParameters.StochasticSoilProfile = value != null - ? value.WrappedObject - : null; - - pipingCalculation.InputParameters.NotifyObservers(); - } - } - - public string StochasticSoilProfileProbability - { - get - { - return pipingCalculation.InputParameters.StochasticSoilProfile != null - ? new RoundedDouble(3, pipingCalculation.InputParameters.StochasticSoilProfile.Probability*100).Value.ToString(CultureInfo.CurrentCulture) - : new RoundedDouble(3).Value.ToString(CultureInfo.CurrentCulture); - } - } - - public DataGridViewComboBoxItemWrapper HydraulicBoundaryLocation - { - get - { - return new DataGridViewComboBoxItemWrapper(pipingCalculation.InputParameters.HydraulicBoundaryLocation); - } - set - { - pipingCalculation.InputParameters.HydraulicBoundaryLocation = value != null - ? value.WrappedObject - : null; - - pipingCalculation.InputParameters.NotifyObservers(); - } - } - - public RoundedDouble DampingFactorExitMean - { - get - { - return pipingCalculation.InputParameters.DampingFactorExit.Mean; - } - set - { - pipingCalculation.InputParameters.DampingFactorExit.Mean = value; - - pipingCalculation.InputParameters.NotifyObservers(); - } - } - - public RoundedDouble PhreaticLevelExitMean - { - get - { - return pipingCalculation.InputParameters.PhreaticLevelExit.Mean; - } - set - { - pipingCalculation.InputParameters.PhreaticLevelExit.Mean = value; - - pipingCalculation.InputParameters.NotifyObservers(); - } - } - - public RoundedDouble EntryPointL - { - get - { - return pipingCalculation.InputParameters.EntryPointL; - } - set - { - pipingCalculation.InputParameters.EntryPointL = value; - - pipingCalculation.InputParameters.NotifyObservers(); - } - } - - public RoundedDouble ExitPointL - { - get - { - return pipingCalculation.InputParameters.ExitPointL; - } - set - { - pipingCalculation.InputParameters.ExitPointL = value; - - pipingCalculation.InputParameters.NotifyObservers(); - } - } - } - #endregion # region Event handling Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj =================================================================== diff -u -r8ed27cd893d87ef66f1bc4f6936407dcff4a284c -r028fa7ac2f1cc6bec17d9db071064febd4f6261b --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision 8ed27cd893d87ef66f1bc4f6936407dcff4a284c) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Ringtoets.Piping.Forms.Test.csproj (.../Ringtoets.Piping.Forms.Test.csproj) (revision 028fa7ac2f1cc6bec17d9db071064febd4f6261b) @@ -99,6 +99,7 @@ + Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationRowTest.cs =================================================================== diff -u --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationRowTest.cs (revision 0) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingCalculationRowTest.cs (revision 028fa7ac2f1cc6bec17d9db071064febd4f6261b) @@ -0,0 +1,313 @@ +// 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 System; +using System.Globalization; +using Core.Common.Base; +using Core.Common.Base.Data; +using Core.Common.Controls.DataGrid; +using NUnit.Framework; +using Ringtoets.HydraRing.Data; +using Ringtoets.Piping.Data; +using Ringtoets.Piping.Data.TestUtil; +using Ringtoets.Piping.Forms.Views; + +namespace Ringtoets.Piping.Forms.Test.Views +{ + [TestFixture] + public class PipingCalculationRowTest + { + [Test] + public void Constructor_WithoutPipingCalculation_ThrowsArgumentNullException() + { + // Call + TestDelegate test = () => new PipingCalculationRow(null); + + // Assert + var paramName = Assert.Throws(test).ParamName; + Assert.AreEqual("pipingCalculation", paramName); + } + + [Test] + public void Constructor_WithPipingCalculation_PropertiesFromPipingCalculation() + { + // Setup + var calculation = PipingCalculationFactory.CreateCalculationWithValidInput(); + + // Call + var row = new PipingCalculationRow(calculation); + + // Assert + Assert.AreSame(calculation, row.PipingCalculation); + Assert.AreEqual(calculation.Name, row.Name); + Assert.AreEqual(calculation.IsRelevant, row.IsRelevant); + Assert.AreEqual(new RoundedDouble(1, calculation.Contribution), new RoundedDouble(1, row.Contribution / 100)); + Assert.AreEqual(calculation.InputParameters.StochasticSoilModel, row.StochasticSoilModel.WrappedObject); + Assert.AreEqual(calculation.InputParameters.StochasticSoilProfile, row.StochasticSoilProfile.WrappedObject); + Assert.AreEqual(calculation.InputParameters.StochasticSoilProfile.Probability.ToString(CultureInfo.CurrentCulture), row.StochasticSoilProfileProbability); + Assert.AreEqual(calculation.InputParameters.HydraulicBoundaryLocation, row.HydraulicBoundaryLocation.WrappedObject); + Assert.AreEqual(calculation.InputParameters.DampingFactorExit.Mean, row.DampingFactorExitMean); + Assert.AreEqual(calculation.InputParameters.PhreaticLevelExit.Mean, row.PhreaticLevelExitMean); + Assert.AreEqual(calculation.InputParameters.EntryPointL, row.EntryPointL); + Assert.AreEqual(calculation.InputParameters.ExitPointL, row.ExitPointL); + } + + [Test] + [TestCase(false)] + [TestCase(true)] + public void IsRelevant_AlwaysOnChange_NotifyObserversAndCalculationPropertyChanged(bool newValue) + { + // Setup + var calculation = PipingCalculationFactory.CreateCalculationWithValidInput(); + var row = new PipingCalculationRow(calculation); + + int counter = 0; + using (new Observer(() => counter++) + { + Observable = calculation + }) + { + // Call + row.IsRelevant = newValue; + + // Assert + Assert.AreEqual(1, counter); + Assert.AreEqual(newValue, calculation.IsRelevant); + } + } + + [Test] + public void Contribution_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged() + { + // Setup + var newValue = new Random().Next(0, 100); + + var calculation = PipingCalculationFactory.CreateCalculationWithValidInput(); + var row = new PipingCalculationRow(calculation); + + int counter = 0; + using (new Observer(() => counter++) + { + Observable = calculation + }) + { + // Call + row.Contribution = (RoundedDouble) newValue; + + // Assert + Assert.AreEqual(1, counter); + Assert.AreEqual(new RoundedDouble(2, newValue), calculation.Contribution * 100); + } + } + + [Test] + public void Name_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged() + { + // Setup + var newValue = "Test new name"; + + var calculation = PipingCalculationFactory.CreateCalculationWithValidInput(); + var row = new PipingCalculationRow(calculation); + + int counter = 0; + using (new Observer(() => counter++) + { + Observable = calculation + }) + { + // Call + row.Name = newValue; + + // Assert + Assert.AreEqual(1, counter); + Assert.AreEqual(newValue, calculation.Name); + } + } + + [Test] + public void StochasticSoilModel_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged() + { + // Setup + var newValue = new DataGridViewComboBoxItemWrapper(new StochasticSoilModel(0, "test", "test")); + + var calculation = PipingCalculationFactory.CreateCalculationWithValidInput(); + var row = new PipingCalculationRow(calculation); + + int counter = 0; + using (new Observer(() => counter++) + { + Observable = calculation.InputParameters + }) + { + // Call + row.StochasticSoilModel = newValue; + + // Assert + Assert.AreEqual(1, counter); + Assert.AreEqual(newValue.WrappedObject, calculation.InputParameters.StochasticSoilModel); + } + } + + [Test] + public void StochasticSoilProfile_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged() + { + // Setup + var newValue = new DataGridViewComboBoxItemWrapper(new StochasticSoilProfile(0, 0, 0)); + + var calculation = PipingCalculationFactory.CreateCalculationWithValidInput(); + var row = new PipingCalculationRow(calculation); + + int counter = 0; + using (new Observer(() => counter++) + { + Observable = calculation.InputParameters + }) + { + // Call + row.StochasticSoilProfile = newValue; + + // Assert + Assert.AreEqual(1, counter); + Assert.AreEqual(newValue.WrappedObject, calculation.InputParameters.StochasticSoilProfile); + } + } + + [Test] + public void HydraulicBoundaryLocation_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged() + { + // Setup + var newValue = new DataGridViewComboBoxItemWrapper(new HydraulicBoundaryLocation(0, "test", 0.0, 0.0)); + + var calculation = PipingCalculationFactory.CreateCalculationWithValidInput(); + var row = new PipingCalculationRow(calculation); + + int counter = 0; + using (new Observer(() => counter++) + { + Observable = calculation.InputParameters + }) + { + // Call + row.HydraulicBoundaryLocation = newValue; + + // Assert + Assert.AreEqual(1, counter); + Assert.AreEqual(newValue.WrappedObject, calculation.InputParameters.HydraulicBoundaryLocation); + } + } + + [Test] + public void DampingFactorExitMean_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged() + { + // Setup + var newValue = new Random().Next(); + + var calculation = PipingCalculationFactory.CreateCalculationWithValidInput(); + var row = new PipingCalculationRow(calculation); + + int counter = 0; + using (new Observer(() => counter++) + { + Observable = calculation.InputParameters + }) + { + // Call + row.DampingFactorExitMean = (RoundedDouble)newValue; + + // Assert + Assert.AreEqual(1, counter); + Assert.AreEqual(new RoundedDouble(2, newValue), calculation.InputParameters.DampingFactorExit.Mean); + } + } + + [Test] + public void PhreaticLevelExitMean_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged() + { + // Setup + var newValue = new Random().Next(); + + var calculation = PipingCalculationFactory.CreateCalculationWithValidInput(); + var row = new PipingCalculationRow(calculation); + + int counter = 0; + using (new Observer(() => counter++) + { + Observable = calculation.InputParameters + }) + { + // Call + row.PhreaticLevelExitMean = (RoundedDouble)newValue; + + // Assert + Assert.AreEqual(1, counter); + Assert.AreEqual(new RoundedDouble(2, newValue), calculation.InputParameters.PhreaticLevelExit.Mean); + } + } + + [Test] + public void EntryPointL_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged() + { + // Setup + var newValue = new Random().Next(); + + var calculation = PipingCalculationFactory.CreateCalculationWithValidInput(); + var row = new PipingCalculationRow(calculation); + + int counter = 0; + using (new Observer(() => counter++) + { + Observable = calculation.InputParameters + }) + { + // Call + row.EntryPointL = (RoundedDouble)newValue; + + // Assert + Assert.AreEqual(1, counter); + Assert.AreEqual(new RoundedDouble(2, newValue), calculation.InputParameters.EntryPointL); + } + } + + [Test] + public void ExitPointL_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged() + { + // Setup + var newValue = new Random().Next(); + + var calculation = PipingCalculationFactory.CreateCalculationWithValidInput(); + var row = new PipingCalculationRow(calculation); + + int counter = 0; + using (new Observer(() => counter++) + { + Observable = calculation.InputParameters + }) + { + // Call + row.ExitPointL = (RoundedDouble)newValue; + + // Assert + Assert.AreEqual(1, counter); + Assert.AreEqual(new RoundedDouble(2, newValue), calculation.InputParameters.ExitPointL); + } + } + } +} \ No newline at end of file