Index: DamClients/DamUI/trunk/src/Dam/Tests/ScenarioTest.cs =================================================================== diff -u --- DamClients/DamUI/trunk/src/Dam/Tests/ScenarioTest.cs (revision 0) +++ DamClients/DamUI/trunk/src/Dam/Tests/ScenarioTest.cs (revision 2783) @@ -0,0 +1,115 @@ +// Copyright (C) Stichting Deltares 2020. All rights reserved. +// +// This file is part of the application DAM - UI. +// +// DAM - UI 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 Deltares.Dam.Data; +using Deltares.Standard; +using Deltares.Standard.Validation; +using NUnit.Framework; + +namespace Deltares.Dam.Tests +{ + [TestFixture] + public class ScenarioTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var scenario = new Scenario(); + + // Assert + Assert.IsInstanceOf(scenario); + Assert.IsInstanceOf(scenario); + + Assert.IsNull(scenario.PolderLevel); + } + + [Test] + public void GivenScenarioWithPolderLevelNotNull_WhenGetParametersAsNameValuePairs_ThenDictionaryContainsPolderLevel() + { + // Given + var random = new Random(21); + var scenario = new Scenario + { + PolderLevel = random.NextDouble() + }; + + // Precondition + Assert.IsNotNull(scenario.PolderLevel); + + // When + var pairs = scenario.GetParametersAsNameValuePairs(); + + // Then + const string variableName = "PolderLevel"; + Assert.IsTrue(pairs.ContainsKey(variableName)); + string pairValue = pairs[variableName]; + string expectedValue = scenario.PolderLevel.Value.ToString(new NumberFormatInfo + { + NumberDecimalSeparator = "." + }); + Assert.AreEqual(expectedValue, pairValue); + } + + [Test] + public void GivenScenarioWithPolderLevelNull_WhenGetParametersAsNameValuePairs_ThenDictionaryDoesNotContainPolderLevel() + { + // Given + var scenario = new Scenario(); + + // Precondition + Assert.IsNull(scenario.PolderLevel); + + // When + var pairs = scenario.GetParametersAsNameValuePairs(); + + // Then + Assert.IsFalse(pairs.ContainsKey("PolderLevel")); + } + + [Test] + public void SetParameterFromNameValuePair_WithValuesForPolderLevel_SetsValues() + { + // Setup + var random = new Random(21); + double numericValue = random.NextDouble(); + string stringValue = numericValue.ToString(new NumberFormatInfo + { + NumberDecimalSeparator = "." + }); + + const string polderLevelName = "PolderLevel"; + + var scenario = new Scenario(); + + // Precondition + Assert.IsNull(scenario.PolderLevel); + + // Call + scenario.SetParameterFromNameValuePair(polderLevelName, stringValue); + + // Assert + Assert.AreEqual(numericValue, scenario.PolderLevel); + } + } +} \ No newline at end of file Index: DamClients/DamUI/trunk/src/Dam/Tests/Deltares.Dam.Tests.csproj =================================================================== diff -u -r2778 -r2783 --- DamClients/DamUI/trunk/src/Dam/Tests/Deltares.Dam.Tests.csproj (.../Deltares.Dam.Tests.csproj) (revision 2778) +++ DamClients/DamUI/trunk/src/Dam/Tests/Deltares.Dam.Tests.csproj (.../Deltares.Dam.Tests.csproj) (revision 2783) @@ -148,6 +148,7 @@ + Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Scenario.cs =================================================================== diff -u -r2774 -r2783 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Scenario.cs (.../Scenario.cs) (revision 2774) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Scenario.cs (.../Scenario.cs) (revision 2783) @@ -597,7 +597,10 @@ [Format("F2")] public double? PolderLevel { - get { return polderLevel; } + get + { + return polderLevel; + } set { DataEventPublisher.BeforeChange(this, ExpressionPolderLevel);