Index: DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Scenario.cs =================================================================== diff -u -r2787 -r2790 --- DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Scenario.cs (.../Scenario.cs) (revision 2787) +++ DamClients/DamUI/trunk/src/DamClientsLibrary/Deltares.Dam.Data/Scenario.cs (.../Scenario.cs) (revision 2790) @@ -86,8 +86,8 @@ private static readonly Expression> ExpressionHeadPl3 = x => x.HeadPl3; private static readonly Expression> ExpressionHeadPl4 = x => x.HeadPl4; private static readonly Expression> ExpressionPolderLevel = x => x.PolderLevel; + private static readonly Expression> ExpressionHeadPl2 = x => x.HeadPl2; - #endregion private CalculationResult calculationResult = CalculationResult.NoRun; @@ -115,7 +115,8 @@ private double? headPl3; private double? headPl4; private double? polderLevel; - + private double? headPl2; + [Browsable(false)] public CalculationResult CalculationResult { @@ -269,6 +270,12 @@ } } + /// + /// Gets or sets the polder level. + /// + /// + /// The polder level. + /// [PropertyOrder(1, 4)] [Unit(UnitType.Length)] [Format("F2")] @@ -547,12 +554,31 @@ } /// + /// Gets or sets the head PL2. + /// + /// + /// The head PL2. + /// + [PropertyOrder(1, 17)] + [Unit(UnitType.Length)] + [Format("F2")] + public double? HeadPl2 { + get { return headPl2; } + set + { + DataEventPublisher.BeforeChange(this, ExpressionHeadPl2); + headPl2 = value; + DataEventPublisher.AfterChange(this, ExpressionHeadPl2); + } + } + + /// /// Gets or sets the required safety factor stability inner slope. /// /// /// The required safety factor stability inner slope. /// - [PropertyOrder(1, 17)] + [PropertyOrder(1, 18)] [Format("F2")] [Label("Required safety factor stability inner slope")] [Description("Required safety factor stability inner slope")] @@ -573,7 +599,7 @@ /// /// The required safety factor stability outer slope. /// - [PropertyOrder(1, 18)] + [PropertyOrder(1, 19)] [Format("F2")] [Label("Required safety factor stability outer slope")] [Description("Required safety factor stability outer slope")] @@ -594,7 +620,7 @@ /// /// The required safety factor piping. /// - [PropertyOrder(1, 19)] + [PropertyOrder(1, 20)] [Format("F2")] [Label("Required safety factor piping")] [Description("Required safety factor piping")] @@ -959,7 +985,7 @@ /// public override string ToString() { - return String.Format("Location={0}, ID={1} RiverLevel={2} RiverLevelLow={3} DikeTableHeight={4} RequiredSafetyFactorStabilityInnerSlope={5} RequiredSafetyFactorStabilityOuterSlope={6} PlLineOffsetBelowDikeTopAtRiver={7} PlLineOffsetBelowDikeToeAtPolder={8} PlLineOffsetBelowDikeTopAtPolder={9} PlLineOffsetBelowShoulderBaseInside={10} UsePlLineOffsetBelowDikeCrestMiddle {11} PlLineOffsetBelowDikeCrestMiddle {12} UsePlLineOffsetFactorBelowShoulderCrest {13} PlLineOffsetFactorBelowShoulderCrest {14} HeadPl3={15} HeadPl4={16} PolderLevel={17}", + return String.Format("Location={0}, ID={1} RiverLevel={2} RiverLevelLow={3} DikeTableHeight={4} RequiredSafetyFactorStabilityInnerSlope={5} RequiredSafetyFactorStabilityOuterSlope={6} PlLineOffsetBelowDikeTopAtRiver={7} PlLineOffsetBelowDikeToeAtPolder={8} PlLineOffsetBelowDikeTopAtPolder={9} PlLineOffsetBelowShoulderBaseInside={10} UsePlLineOffsetBelowDikeCrestMiddle {11} PlLineOffsetBelowDikeCrestMiddle {12} UsePlLineOffsetFactorBelowShoulderCrest {13} PlLineOffsetFactorBelowShoulderCrest {14} HeadPl3={15} HeadPl4={16} PolderLevel={17} HeadPl2={18}", Location.Name, LocationScenarioID, RiverLevel, RiverLevelLow.HasValue ? RiverLevelLow.Value.ToString(CultureInfo.InvariantCulture) : "?", DikeTableHeight.HasValue ? DikeTableHeight.Value.ToString(CultureInfo.InvariantCulture) : "?", @@ -979,7 +1005,8 @@ PlLineOffsetFactorBelowShoulderCrest.Value.ToString(CultureInfo.InvariantCulture) : "?", HeadPl3.HasValue ? HeadPl3.Value.ToString(CultureInfo.InvariantCulture) : "?", HeadPl4.HasValue ? HeadPl4.Value.ToString(CultureInfo.InvariantCulture) : "?", - PolderLevel.HasValue ? PolderLevel.Value.ToString(CultureInfo.InvariantCulture) : "?"); + PolderLevel.HasValue ? PolderLevel.Value.ToString(CultureInfo.InvariantCulture) : "?", + HeadPl2.HasValue ? HeadPl2.Value.ToString(CultureInfo.InvariantCulture) : "?"); } public Dictionary GetParametersAsNameValuePairs() @@ -1040,6 +1067,12 @@ { nameValuePairs.Add(ScenarioParameterNames.PolderLevel, PolderLevel.Value.ToString(numberFormatInfo)); } + + if (HeadPl2 != null) + { + nameValuePairs.Add(ScenarioParameterNames.HeadPl2, HeadPl2.Value.ToString(numberFormatInfo)); + } + return nameValuePairs; } @@ -1087,6 +1120,8 @@ HeadPl4 = Convert.ToDouble(parameterValue, numberFormatInfo); if (parameterName.Equals(ScenarioParameterNames.PolderLevel)) PolderLevel = Convert.ToDouble(parameterValue, numberFormatInfo); + if (parameterName.Equals(ScenarioParameterNames.HeadPl2)) + HeadPl2 = Convert.ToDouble(parameterValue, numberFormatInfo); } public bool IsVisible(string property) @@ -1167,5 +1202,6 @@ public const string HeadPl3 = "HeadPL3"; public const string HeadPl4 = "HeadPL4"; public const string PolderLevel = "PolderLevel"; + public const string HeadPl2 = "HeadPL2"; } } Index: DamClients/DamUI/trunk/src/Dam/Tests/ScenarioTest.cs =================================================================== diff -u -r2783 -r2790 --- DamClients/DamUI/trunk/src/Dam/Tests/ScenarioTest.cs (.../ScenarioTest.cs) (revision 2783) +++ DamClients/DamUI/trunk/src/Dam/Tests/ScenarioTest.cs (.../ScenarioTest.cs) (revision 2790) @@ -42,6 +42,7 @@ Assert.IsInstanceOf(scenario); Assert.IsNull(scenario.PolderLevel); + Assert.IsNull(scenario.HeadPl2); } [Test] @@ -111,5 +112,73 @@ // Assert Assert.AreEqual(numericValue, scenario.PolderLevel); } + + [Test] + public void GivenScenarioWithHeadPl2NotNull_WhenGetParametersAsNameValuePairs_ThenDictionaryContainsPolderLevel() + { + // Given + var random = new Random(21); + var scenario = new Scenario + { + HeadPl2 = random.NextDouble() + }; + + // Precondition + Assert.IsNotNull(scenario.HeadPl2); + + // When + var pairs = scenario.GetParametersAsNameValuePairs(); + + // Then + const string variableName = "HeadPL2"; + Assert.IsTrue(pairs.ContainsKey(variableName)); + string pairValue = pairs[variableName]; + string expectedValue = scenario.HeadPl2.Value.ToString(new NumberFormatInfo + { + NumberDecimalSeparator = "." + }); + Assert.AreEqual(expectedValue, pairValue); + } + + [Test] + public void GivenScenarioWithHeadPl2Null_WhenGetParametersAsNameValuePairs_ThenDictionaryDoesNotContainPolderLevel() + { + // Given + var scenario = new Scenario(); + + // Precondition + Assert.IsNull(scenario.HeadPl2); + + // When + var pairs = scenario.GetParametersAsNameValuePairs(); + + // Then + Assert.IsFalse(pairs.ContainsKey("HeadPl2")); + } + + [Test] + public void SetParameterFromNameValuePair_WithValuesForheadPl2_SetsValues() + { + // Setup + var random = new Random(21); + double numericValue = random.NextDouble(); + string stringValue = numericValue.ToString(new NumberFormatInfo + { + NumberDecimalSeparator = "." + }); + + const string headPL2Name = "HeadPL2"; + + var scenario = new Scenario(); + + // Precondition + Assert.IsNull(scenario.PolderLevel); + + // Call + scenario.SetParameterFromNameValuePair(headPL2Name, stringValue); + + // Assert + Assert.AreEqual(numericValue, scenario.HeadPl2); + } } } \ No newline at end of file