Index: Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismSectionResultRow.cs =================================================================== diff -u -rf88343c0590cb04c7135ce141872940e59325927 -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismSectionResultRow.cs (.../ClosingStructuresFailureMechanismSectionResultRow.cs) (revision f88343c0590cb04c7135ce141872940e59325927) +++ Ringtoets/ClosingStructures/src/Ringtoets.ClosingStructures.Forms/Views/ClosingStructuresFailureMechanismSectionResultRow.cs (.../ClosingStructuresFailureMechanismSectionResultRow.cs) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -21,6 +21,7 @@ using System; using System.ComponentModel; +using Core.Common.Base.Data; using Ringtoets.ClosingStructures.Data; using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Forms.TypeConverters; @@ -41,6 +42,19 @@ /// Thrown when is null. public ClosingStructuresFailureMechanismSectionResultRow(ClosingStructuresFailureMechanismSectionResult sectionResult) : base(sectionResult) {} + [TypeConverter(typeof(NoProbabilityValueRoundedDoubleConverter))] + public override RoundedDouble AssessmentLayerThree + { + get + { + return base.AssessmentLayerThree; + } + set + { + base.AssessmentLayerThree = value; + } + } + /// /// Gets the . /// Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismResultViewTest.cs =================================================================== diff -u -re25d4d9814eac847e4e004df35a91a938ee01912 -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismResultViewTest.cs (.../ClosingStructuresFailureMechanismResultViewTest.cs) (revision e25d4d9814eac847e4e004df35a91a938ee01912) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismResultViewTest.cs (.../ClosingStructuresFailureMechanismResultViewTest.cs) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -276,7 +276,8 @@ Assert.AreEqual(result1.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value); Assert.AreEqual("-", cells[assessmentLayerTwoAIndex].FormattedValue); - Assert.AreEqual(result1.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + Assert.AreEqual(ProbabilityFormattingHelper.Format(result1.AssessmentLayerThree), + cells[assessmentLayerThreeIndex].FormattedValue); DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); @@ -286,7 +287,8 @@ Assert.AreEqual("Section 2", cells[nameColumnIndex].FormattedValue); Assert.AreEqual(result2.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value); Assert.AreEqual("-", cells[assessmentLayerTwoAIndex].FormattedValue); - Assert.AreEqual(result2.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + Assert.AreEqual(ProbabilityFormattingHelper.Format(result2.AssessmentLayerThree), + cells[assessmentLayerThreeIndex].FormattedValue); DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerTwoAIndex], true); DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); @@ -296,7 +298,8 @@ Assert.AreEqual("Section 3", cells[nameColumnIndex].FormattedValue); Assert.AreEqual(result3.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value); Assert.AreEqual("-", cells[assessmentLayerTwoAIndex].FormattedValue); - Assert.AreEqual(result3.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + Assert.AreEqual(ProbabilityFormattingHelper.Format(result3.AssessmentLayerThree), + cells[assessmentLayerThreeIndex].FormattedValue); DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerTwoAIndex], true); DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismSectionResultRowTest.cs =================================================================== diff -u -rb28a844780b613e1901fa82328ba3917f485c729 -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismSectionResultRowTest.cs (.../ClosingStructuresFailureMechanismSectionResultRowTest.cs) (revision b28a844780b613e1901fa82328ba3917f485c729) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismSectionResultRowTest.cs (.../ClosingStructuresFailureMechanismSectionResultRowTest.cs) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -19,6 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; @@ -51,6 +53,8 @@ Assert.AreEqual(result.AssessmentLayerTwoA, row.AssessmentLayerTwoA); TestHelper.AssertTypeConverter( nameof(ClosingStructuresFailureMechanismSectionResultRow.AssessmentLayerTwoA)); + TestHelper.AssertTypeConverter( + nameof(ClosingStructuresFailureMechanismSectionResultRow.AssessmentLayerThree)); } [Test] @@ -164,6 +168,23 @@ Assert.AreSame(expectedCalculation, calculation); } + [Test] + public void AssessmentLayerThree_ValueSet_ReturnExpectedValue() + { + // Setup + var random = new Random(21); + RoundedDouble assessmentLayerThree = random.NextRoundedDouble(); + + var sectionResult = new ClosingStructuresFailureMechanismSectionResult(CreateSection()); + var row = new ClosingStructuresFailureMechanismSectionResultRow(sectionResult); + + // Call + row.AssessmentLayerThree = assessmentLayerThree; + + // Assert + Assert.AreEqual(assessmentLayerThree, sectionResult.AssessmentLayerThree); + } + private static FailureMechanismSection CreateSection() { return new FailureMechanismSection("name", new[] Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj =================================================================== diff -u -r9fe25ebfb1f70f00d66564ef2a89f6e22c27dce4 -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 9fe25ebfb1f70f00d66564ef2a89f6e22c27dce4) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Ringtoets.Common.Forms.csproj (.../Ringtoets.Common.Forms.csproj) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -130,6 +130,7 @@ Form + Index: Ringtoets/Common/src/Ringtoets.Common.Forms/TypeConverters/NoProbabilityValueRoundedDoubleConverter.cs =================================================================== diff -u --- Ringtoets/Common/src/Ringtoets.Common.Forms/TypeConverters/NoProbabilityValueRoundedDoubleConverter.cs (revision 0) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/TypeConverters/NoProbabilityValueRoundedDoubleConverter.cs (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -0,0 +1,93 @@ +// Copyright (C) Stichting Deltares 2017. 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.ComponentModel; +using System.Globalization; +using Core.Common.Base.Data; +using Ringtoets.Common.Forms.Helpers; +using Ringtoets.Common.Forms.Properties; + +namespace Ringtoets.Common.Forms.TypeConverters +{ + public class NoProbabilityValueRoundedDoubleConverter : TypeConverter + { + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + var doubleValue = (RoundedDouble) value; + if (destinationType == typeof(string)) + { + if (double.IsNaN(doubleValue)) + { + return Resources.RoundedRouble_No_result_dash; + } + if (double.IsNegativeInfinity(doubleValue)) + { + return Core.Common.Base.Properties.Resources.RoundedDouble_ToString_NegativeInfinity; + } + if (double.IsPositiveInfinity(doubleValue)) + { + return Core.Common.Base.Properties.Resources.RoundedDouble_ToString_PositiveInfinity; + } + + return ProbabilityFormattingHelper.Format(doubleValue); + } + return base.ConvertTo(context, culture, value, destinationType); + } + + public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) + { + var text = value as string; + if (text != null) + { + if (string.IsNullOrWhiteSpace(text) || text.Trim() == Resources.RoundedRouble_No_result_dash) + { + return RoundedDouble.NaN; + } + + try + { + return (RoundedDouble)Convert.ToDouble(text); + } + catch (FormatException exception) + { + throw new NotSupportedException(Core.Common.Base.Properties.Resources.RoundedDoubleConverter_ConvertFrom_String_must_represent_number, + exception); + } + catch (OverflowException exception) + { + throw new NotSupportedException(Core.Common.Base.Properties.Resources.RoundedDoubleConverter_ConvertFrom_String_too_small_or_too_big_to_represent_as_double, + exception); + } + } + return base.ConvertFrom(context, culture, value); + } + + public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) + { + if (sourceType == typeof(string)) + { + return true; + } + return base.CanConvertFrom(context, sourceType); + } + } +} \ No newline at end of file Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismSectionResultRow.cs =================================================================== diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismSectionResultRow.cs (.../FailureMechanismSectionResultRow.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1) +++ Ringtoets/Common/src/Ringtoets.Common.Forms/Views/FailureMechanismSectionResultRow.cs (.../FailureMechanismSectionResultRow.cs) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -80,15 +80,15 @@ /// Gets or sets the value representing the result of the layer 3 assessment. /// [TypeConverter(typeof(NoValueRoundedDoubleConverter))] - public RoundedDouble AssessmentLayerThree + public virtual RoundedDouble AssessmentLayerThree { get { return SectionResult.AssessmentLayerThree; } set { - SectionResult.AssessmentLayerThree = value; + SectionResult.AssessmentLayerThree = value.ToPrecision(SectionResult.AssessmentLayerThree.NumberOfDecimalPlaces); } } Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj =================================================================== diff -u -r7b7bd75dc1c1327386c9be96b5d480565bb8ecd6 -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 7b7bd75dc1c1327386c9be96b5d480565bb8ecd6) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Ringtoets.Common.Forms.Test.csproj (.../Ringtoets.Common.Forms.Test.csproj) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -121,6 +121,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TypeConverters/NoProbabilityValueRoundedDoubleConverterTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TypeConverters/NoProbabilityValueRoundedDoubleConverterTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TypeConverters/NoProbabilityValueRoundedDoubleConverterTest.cs (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -0,0 +1,304 @@ +// Copyright (C) Stichting Deltares 2017. 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.ComponentModel; +using System.Globalization; +using Core.Common.Base.Data; +using NUnit.Framework; +using Rhino.Mocks; +using Ringtoets.Common.Forms.Helpers; +using Ringtoets.Common.Forms.TypeConverters; + +namespace Ringtoets.Common.Forms.Test.TypeConverters +{ + [TestFixture] + public class NoProbabilityValueRoundedDoubleConverterTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var converter = new NoProbabilityValueRoundedDoubleConverter(); + + // Assert + Assert.IsInstanceOf(converter); + } + + [Test] + public void CanConvertFrom_String_ReturnTrue() + { + // Setup + var converter = new NoProbabilityValueRoundedDoubleConverter(); + + // Call + bool canConvertFromString = converter.CanConvertFrom(typeof(string)); + + // Assert + Assert.IsTrue(canConvertFromString); + } + + [Test] + public void CanConvertFrom_OtherThanString_ReturnFalse() + { + // Setup + var converter = new NoProbabilityValueRoundedDoubleConverter(); + + // Call + bool canConvertFromString = converter.CanConvertFrom(typeof(object)); + + // Assert + Assert.IsFalse(canConvertFromString); + } + + [Test] + public void ConvertFrom_Object_ThrowNotSupportedException() + { + // Setup + var converter = new NoProbabilityValueRoundedDoubleConverter(); + + // Call + TestDelegate call = () => converter.ConvertFrom(new object()); + + // Assert + Assert.Throws(call); + } + + [Test] + [TestCase("")] + [TestCase(" ")] + [TestCase("-")] + [TestCase("NaN")] + public void ConvertFrom_NoValueText_ReturnNaN(string text) + { + // Setup + var converter = new NoProbabilityValueRoundedDoubleConverter(); + + // Call + var result = (RoundedDouble) converter.ConvertFrom(text); + + // Assert + Assert.IsNaN(result); + } + + [Test] + [SetCulture("nl-NL")] + [TestCase(123.4567)] + [TestCase(-9.87654321)] + public void ConvertFrom_SomeNumericalTextInDutchCulture_ReturnConvertedRoundedDouble(double value) + { + var input = (RoundedDouble) value; + DoConvertFrom_SomeNumericalTextInCurrentCulture_ReturnConvertedDouble(input); + } + + [Test] + [SetCulture("en-US")] + [TestCase(12.34)] + [TestCase(-0.96834715)] + public void ConvertFrom_SomeNumericalTextInEnglishCulture_ReturnConvertedRoundedDouble(double value) + { + var input = (RoundedDouble) value; + DoConvertFrom_SomeNumericalTextInCurrentCulture_ReturnConvertedDouble(input); + } + + [Test] + public void ConvertFrom_TextDoesNotRepresentNumber_ThrowNotSupportedException() + { + // Setup + var mocks = new MockRepository(); + var context = mocks.Stub(); + mocks.ReplayAll(); + + const string text = "I'm not a number!"; + + var converter = new NoProbabilityValueRoundedDoubleConverter(); + + // Call + TestDelegate call = () => converter.ConvertFrom(context, CultureInfo.CurrentCulture, text); + + // Assert + string message = Assert.Throws(call).Message; + Assert.AreEqual("De tekst moet een getal zijn.", message); + mocks.VerifyAll(); + } + + [Test] + public void ConvertFrom_TextTooLongToStoreInDouble_ThrowNotSupportedException() + { + // Setup + var mocks = new MockRepository(); + var context = mocks.Stub(); + mocks.ReplayAll(); + + string text = "1" + double.MaxValue.ToString(CultureInfo.CurrentCulture); + + var converter = new NoProbabilityValueRoundedDoubleConverter(); + + // Call + TestDelegate call = () => converter.ConvertFrom(context, CultureInfo.CurrentCulture, text); + + // Assert + string message = Assert.Throws(call).Message; + Assert.AreEqual("De tekst is een getal dat te groot of te klein is om gerepresenteerd te worden.", message); + mocks.VerifyAll(); + } + + [Test] + public void CanConvertTo_ToString_ReturnTrue() + { + // Setup + var converter = new NoProbabilityValueRoundedDoubleConverter(); + + // Call + bool canConvertToString = converter.CanConvertTo(typeof(string)); + + // Assert + Assert.IsTrue(canConvertToString); + } + + [Test] + public void CanConvertTo_ToObject_ReturnFalse() + { + // Setup + var converter = new NoProbabilityValueRoundedDoubleConverter(); + + // Call + bool canConvertToObject = converter.CanConvertTo(typeof(object)); + + // Assert + Assert.IsFalse(canConvertToObject); + } + + [Test] + public void ConvertTo_Object_ThrowNotSupportedException() + { + // Setup + var converter = new NoProbabilityValueRoundedDoubleConverter(); + var input = (RoundedDouble) 1.1; + + // Call + TestDelegate call = () => converter.ConvertTo(input, typeof(object)); + + // Assert + Assert.Throws(call); + } + + [Test] + public void ConvertTo_NaNToString_ReturnHyphen() + { + // Setup + var converter = new NoProbabilityValueRoundedDoubleConverter(); + + + // Call + var text = (string) converter.ConvertTo(RoundedDouble.NaN, typeof(string)); + + // Assert + Assert.AreEqual("-", text); + } + + [Test] + public void ConvertTo_PositiveInfinityToString_ReturnInfinity() + { + // Setup + var converter = new NoProbabilityValueRoundedDoubleConverter(); + var input = (RoundedDouble) double.PositiveInfinity; + + // Call + var text = (string) converter.ConvertTo(input, typeof(string)); + + // Assert + Assert.AreEqual("Oneindig", text); + } + + [Test] + public void ConvertTo_NegativeInfinityToString_ReturnNegativeInfinity() + { + // Setup + var converter = new NoProbabilityValueRoundedDoubleConverter(); + var input = (RoundedDouble) double.NegativeInfinity; + + // Call + var text = (string) converter.ConvertTo(input, typeof(string)); + + // Assert + Assert.AreEqual("-Oneindig", text); + } + + [Test] + [SetCulture("nl-NL")] + [TestCase(-0.000235)] + [TestCase(0.0069)] + [TestCase(0.000000000000000069)] + public void ConvertTo_NumberToString_ReturnStringInLocalDutchCulture(double input) + { + // Setup + var value = (RoundedDouble) input; + var converter = new NoProbabilityValueRoundedDoubleConverter(); + + // Call + var text = (string) converter.ConvertTo(value, typeof(string)); + + // Assert + string expectedText = ProbabilityFormattingHelper.Format(value); + Assert.AreEqual(expectedText, text); + } + + [Test] + [SetCulture("en-US")] + [TestCase(-0.0000658)] + [TestCase(0.000006788)] + [TestCase(-0.000000000000000069)] + public void ConvertTo_NumberToString_ReturnStringInLocalEnglishCulture(double input) + { + // Setup + var value = (RoundedDouble) input; + var converter = new NoProbabilityValueRoundedDoubleConverter(); + + // Call + var text = (string) converter.ConvertTo(value, typeof(string)); + + // Assert + string expectedText = ProbabilityFormattingHelper.Format(value); + Assert.AreEqual(expectedText, text); + } + + private static void DoConvertFrom_SomeNumericalTextInCurrentCulture_ReturnConvertedDouble(RoundedDouble input) + { + // Setup + var mocks = new MockRepository(); + var context = mocks.Stub(); + mocks.ReplayAll(); + + string text = input.ToString(); + + var converter = new NoProbabilityValueRoundedDoubleConverter(); + + // Call + object conversionResult = converter.ConvertFrom(context, CultureInfo.CurrentCulture, text); + + // Assert + Assert.AreEqual(input, conversionResult); + Assert.IsInstanceOf(conversionResult); + mocks.VerifyAll(); + } + } +} \ No newline at end of file Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismSectionResultRow.cs =================================================================== diff -u -raeb6e1a439617630e7613b9ed5af152c345fa2c6 -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismSectionResultRow.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultRow.cs) (revision aeb6e1a439617630e7613b9ed5af152c345fa2c6) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.Forms/Views/GrassCoverErosionInwardsFailureMechanismSectionResultRow.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultRow.cs) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -21,6 +21,7 @@ using System; using System.ComponentModel; +using Core.Common.Base.Data; using Ringtoets.Common.Forms.TypeConverters; using Ringtoets.Common.Forms.Views; using Ringtoets.GrassCoverErosionInwards.Data; @@ -42,6 +43,19 @@ /// null. public GrassCoverErosionInwardsFailureMechanismSectionResultRow(GrassCoverErosionInwardsFailureMechanismSectionResult sectionResult) : base(sectionResult) {} + [TypeConverter(typeof(NoProbabilityValueRoundedDoubleConverter))] + public override RoundedDouble AssessmentLayerThree + { + get + { + return base.AssessmentLayerThree; + } + set + { + base.AssessmentLayerThree = value; + } + } + /// /// Gets the value representing the result of the layer 2a assessment. /// Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismSectionResultRowTest.cs =================================================================== diff -u -r3c5eb8dc63626571ddee036cac675707bd0b0ff0 -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismSectionResultRowTest.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultRowTest.cs) (revision 3c5eb8dc63626571ddee036cac675707bd0b0ff0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.Forms.Test/Views/GrassCoverErosionInwardsFailureMechanismSectionResultRowTest.cs (.../GrassCoverErosionInwardsFailureMechanismSectionResultRowTest.cs) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -19,6 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; @@ -50,6 +52,8 @@ Assert.AreEqual(result.AssessmentLayerTwoA, row.AssessmentLayerTwoA); TestHelper.AssertTypeConverter( nameof(GrassCoverErosionInwardsFailureMechanismSectionResultRow.AssessmentLayerTwoA)); + TestHelper.AssertTypeConverter( + nameof(GrassCoverErosionInwardsFailureMechanismSectionResultRow.AssessmentLayerThree)); } [Test] @@ -167,6 +171,23 @@ Assert.AreSame(grassCoverErosionInwardsCalculation, calculation); } + [Test] + public void AssessmentLayerThree_ValueSet_ReturnExpectedValue() + { + // Setup + var random = new Random(21); + RoundedDouble assessmentLayerThree = random.NextRoundedDouble(); + + var sectionResult = new GrassCoverErosionInwardsFailureMechanismSectionResult(CreateSection()); + var row = new GrassCoverErosionInwardsFailureMechanismSectionResultRow(sectionResult); + + // Call + row.AssessmentLayerThree = assessmentLayerThree; + + // Assert + Assert.AreEqual(assessmentLayerThree, sectionResult.AssessmentLayerThree); + } + private static FailureMechanismSection CreateSection() { return new FailureMechanismSection("A", new[] Index: Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismSectionResultRow.cs =================================================================== diff -u -r4bf59bb3506b840b284efe0c0f4431b7876e0e5b -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismSectionResultRow.cs (.../HeightStructuresFailureMechanismSectionResultRow.cs) (revision 4bf59bb3506b840b284efe0c0f4431b7876e0e5b) +++ Ringtoets/HeightStructures/src/Ringtoets.HeightStructures.Forms/Views/HeightStructuresFailureMechanismSectionResultRow.cs (.../HeightStructuresFailureMechanismSectionResultRow.cs) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -21,6 +21,7 @@ using System; using System.ComponentModel; +using Core.Common.Base.Data; using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Forms.TypeConverters; using Ringtoets.Common.Forms.Views; @@ -40,6 +41,19 @@ /// Thrown when is null. public HeightStructuresFailureMechanismSectionResultRow(HeightStructuresFailureMechanismSectionResult sectionResult) : base(sectionResult) {} + [TypeConverter(typeof(NoProbabilityValueRoundedDoubleConverter))] + public override RoundedDouble AssessmentLayerThree + { + get + { + return base.AssessmentLayerThree; + } + set + { + base.AssessmentLayerThree = value; + } + } + /// /// Gets the assessment layer two a of the . /// Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismSectionResultRowTest.cs =================================================================== diff -u -rb28a844780b613e1901fa82328ba3917f485c729 -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismSectionResultRowTest.cs (.../HeightStructuresFailureMechanismSectionResultRowTest.cs) (revision b28a844780b613e1901fa82328ba3917f485c729) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismSectionResultRowTest.cs (.../HeightStructuresFailureMechanismSectionResultRowTest.cs) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -19,6 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; @@ -51,6 +53,8 @@ Assert.AreEqual(result.AssessmentLayerTwoA, row.AssessmentLayerTwoA); TestHelper.AssertTypeConverter( nameof(HeightStructuresFailureMechanismSectionResultRow.AssessmentLayerTwoA)); + TestHelper.AssertTypeConverter( + nameof(HeightStructuresFailureMechanismSectionResultRow.AssessmentLayerThree)); } [Test] @@ -164,6 +168,23 @@ Assert.AreSame(expectedCalculation, calculation); } + [Test] + public void AssessmentLayerThree_ValueSet_ReturnExpectedValue() + { + // Setup + var random = new Random(21); + RoundedDouble assessmentLayerThree = random.NextRoundedDouble(); + + var sectionResult = new HeightStructuresFailureMechanismSectionResult(CreateSection()); + var row = new HeightStructuresFailureMechanismSectionResultRow(sectionResult); + + // Call + row.AssessmentLayerThree = assessmentLayerThree; + + // Assert + Assert.AreEqual(assessmentLayerThree, sectionResult.AssessmentLayerThree); + } + private static FailureMechanismSection CreateSection() { return new FailureMechanismSection("name", new[] Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismSectionResultRow.cs =================================================================== diff -u -r5906f61fff270a7526253bea07dfecdf680898ed -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismSectionResultRow.cs (.../MacroStabilityInwardsFailureMechanismSectionResultRow.cs) (revision 5906f61fff270a7526253bea07dfecdf680898ed) +++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.Forms/Views/MacroStabilityInwardsFailureMechanismSectionResultRow.cs (.../MacroStabilityInwardsFailureMechanismSectionResultRow.cs) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using Core.Common.Base.Data; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Forms.TypeConverters; using Ringtoets.Common.Forms.Views; @@ -55,6 +56,19 @@ this.calculations = calculations; } + [TypeConverter(typeof(NoProbabilityValueRoundedDoubleConverter))] + public override RoundedDouble AssessmentLayerThree + { + get + { + return base.AssessmentLayerThree; + } + set + { + base.AssessmentLayerThree = value; + } + } + /// /// Gets the assessment layer two a of the . /// Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismSectionResultRowTest.cs =================================================================== diff -u -r650fc7b43cb6729baee51d079f0377df8d7a3de9 -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismSectionResultRowTest.cs (.../MacroStabilityInwardsFailureMechanismSectionResultRowTest.cs) (revision 650fc7b43cb6729baee51d079f0377df8d7a3de9) +++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.Forms.Test/Views/MacroStabilityInwardsFailureMechanismSectionResultRowTest.cs (.../MacroStabilityInwardsFailureMechanismSectionResultRowTest.cs) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -53,6 +53,8 @@ Assert.AreEqual(result.GetAssessmentLayerTwoA(Enumerable.Empty()), row.AssessmentLayerTwoA); TestHelper.AssertTypeConverter( nameof(MacroStabilityInwardsFailureMechanismSectionResultRow.AssessmentLayerTwoA)); + TestHelper.AssertTypeConverter( + nameof(MacroStabilityInwardsFailureMechanismSectionResultRow.AssessmentLayerThree)); } [Test] @@ -164,6 +166,24 @@ Assert.AreEqual(expected, assessmentLayerTwoA, 1e-6); } + [Test] + public void AssessmentLayerThree_ValueSet_ReturnExpectedValue() + { + // Setup + var random = new Random(21); + RoundedDouble assessmentLayerThree = random.NextRoundedDouble(); + + var sectionResult = new MacroStabilityInwardsFailureMechanismSectionResult(CreateSection()); + var row = new MacroStabilityInwardsFailureMechanismSectionResultRow(sectionResult, + Enumerable.Empty()); + + // Call + row.AssessmentLayerThree = assessmentLayerThree; + + // Assert + Assert.AreEqual(assessmentLayerThree, sectionResult.AssessmentLayerThree); + } + private static FailureMechanismSection CreateSection() { return new FailureMechanismSection("name", new[] Index: Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismSectionResultRow.cs =================================================================== diff -u -r5906f61fff270a7526253bea07dfecdf680898ed -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismSectionResultRow.cs (.../PipingFailureMechanismSectionResultRow.cs) (revision 5906f61fff270a7526253bea07dfecdf680898ed) +++ Ringtoets/Piping/src/Ringtoets.Piping.Forms/Views/PipingFailureMechanismSectionResultRow.cs (.../PipingFailureMechanismSectionResultRow.cs) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -23,6 +23,7 @@ using System.Collections.Generic; using System.ComponentModel; using System.Linq; +using Core.Common.Base.Data; using Ringtoets.Common.Data.Calculation; using Ringtoets.Common.Forms.TypeConverters; using Ringtoets.Common.Forms.Views; @@ -55,6 +56,19 @@ this.calculations = calculations; } + [TypeConverter(typeof(NoProbabilityValueRoundedDoubleConverter))] + public override RoundedDouble AssessmentLayerThree + { + get + { + return base.AssessmentLayerThree; + } + set + { + base.AssessmentLayerThree = value; + } + } + /// /// Gets the assessment layer two a of the . /// Index: Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismSectionResultRowTest.cs =================================================================== diff -u -r81fa8a9bf3bd503cbd280e88b8f6037a840cff12 -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismSectionResultRowTest.cs (.../PipingFailureMechanismSectionResultRowTest.cs) (revision 81fa8a9bf3bd503cbd280e88b8f6037a840cff12) +++ Ringtoets/Piping/test/Ringtoets.Piping.Forms.Test/Views/PipingFailureMechanismSectionResultRowTest.cs (.../PipingFailureMechanismSectionResultRowTest.cs) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -53,6 +53,8 @@ Assert.AreEqual(result.GetAssessmentLayerTwoA(Enumerable.Empty()), row.AssessmentLayerTwoA); TestHelper.AssertTypeConverter( nameof(PipingFailureMechanismSectionResultRow.AssessmentLayerTwoA)); + TestHelper.AssertTypeConverter( + nameof(PipingFailureMechanismSectionResultRow.AssessmentLayerThree)); } [Test] @@ -164,6 +166,24 @@ Assert.AreEqual(expected, assessmentLayerTwoA, 1e-6); } + [Test] + public void AssessmentLayerThree_ValueSet_ReturnExpectedValue() + { + // Setup + var random = new Random(21); + RoundedDouble assessmentLayerThree = random.NextRoundedDouble(); + + var sectionResult = new PipingFailureMechanismSectionResult(CreateSection()); + var row = new PipingFailureMechanismSectionResultRow(sectionResult, + Enumerable.Empty()); + + // Call + row.AssessmentLayerThree = assessmentLayerThree; + + // Assert + Assert.AreEqual(assessmentLayerThree, sectionResult.AssessmentLayerThree); + } + private static FailureMechanismSection CreateSection() { return new FailureMechanismSection("name", new[] Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismSectionResultRow.cs =================================================================== diff -u -rff948d4633181ead2677ab35467a93b4118c6751 -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismSectionResultRow.cs (.../StabilityPointStructuresFailureMechanismSectionResultRow.cs) (revision ff948d4633181ead2677ab35467a93b4118c6751) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Forms/Views/StabilityPointStructuresFailureMechanismSectionResultRow.cs (.../StabilityPointStructuresFailureMechanismSectionResultRow.cs) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -21,6 +21,7 @@ using System; using System.ComponentModel; +using Core.Common.Base.Data; using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Forms.TypeConverters; using Ringtoets.Common.Forms.Views; @@ -53,6 +54,19 @@ } } + [TypeConverter(typeof(NoProbabilityValueRoundedDoubleConverter))] + public override RoundedDouble AssessmentLayerThree + { + get + { + return base.AssessmentLayerThree; + } + set + { + base.AssessmentLayerThree = value; + } + } + /// /// Gets the of the wrapped /// . Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismResultViewTest.cs =================================================================== diff -u -re25d4d9814eac847e4e004df35a91a938ee01912 -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismResultViewTest.cs (.../StabilityPointStructuresFailureMechanismResultViewTest.cs) (revision e25d4d9814eac847e4e004df35a91a938ee01912) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismResultViewTest.cs (.../StabilityPointStructuresFailureMechanismResultViewTest.cs) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -277,7 +277,8 @@ Assert.AreEqual(result1.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value); Assert.AreEqual("-", cells[assessmentLayerTwoAIndex].FormattedValue); - Assert.AreEqual(result1.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + Assert.AreEqual(ProbabilityFormattingHelper.Format(result1.AssessmentLayerThree), + cells[assessmentLayerThreeIndex].FormattedValue); DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerTwoAIndex]); DataGridViewTestHelper.AssertCellIsDisabled(cells[assessmentLayerThreeIndex]); @@ -287,7 +288,8 @@ Assert.AreEqual("Section 2", cells[nameColumnIndex].FormattedValue); Assert.AreEqual(result2.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value); Assert.AreEqual("-", cells[assessmentLayerTwoAIndex].FormattedValue); - Assert.AreEqual(result2.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + Assert.AreEqual(ProbabilityFormattingHelper.Format(result2.AssessmentLayerThree), + cells[assessmentLayerThreeIndex].FormattedValue); DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerTwoAIndex], true); DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); @@ -297,7 +299,8 @@ Assert.AreEqual("Section 3", cells[nameColumnIndex].FormattedValue); Assert.AreEqual(result3.AssessmentLayerOne, cells[assessmentLayerOneIndex].Value); Assert.AreEqual("-", cells[assessmentLayerTwoAIndex].FormattedValue); - Assert.AreEqual(result3.AssessmentLayerThree.ToString(), cells[assessmentLayerThreeIndex].FormattedValue); + Assert.AreEqual(ProbabilityFormattingHelper.Format(result3.AssessmentLayerThree), + cells[assessmentLayerThreeIndex].FormattedValue); DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerTwoAIndex], true); DataGridViewTestHelper.AssertCellIsEnabled(cells[assessmentLayerThreeIndex]); Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismSectionResultRowTest.cs =================================================================== diff -u -rb28a844780b613e1901fa82328ba3917f485c729 -r0aacf2dc29138c69f365fe26a143d4e83b172dbe --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismSectionResultRowTest.cs (.../StabilityPointStructuresFailureMechanismSectionResultRowTest.cs) (revision b28a844780b613e1901fa82328ba3917f485c729) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismSectionResultRowTest.cs (.../StabilityPointStructuresFailureMechanismSectionResultRowTest.cs) (revision 0aacf2dc29138c69f365fe26a143d4e83b172dbe) @@ -19,6 +19,8 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; +using Core.Common.Base.Data; using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; @@ -51,6 +53,8 @@ Assert.AreEqual(result.AssessmentLayerTwoA, row.AssessmentLayerTwoA); TestHelper.AssertTypeConverter( nameof(StabilityPointStructuresFailureMechanismSectionResultRow.AssessmentLayerTwoA)); + TestHelper.AssertTypeConverter( + nameof(StabilityPointStructuresFailureMechanismSectionResultRow.AssessmentLayerThree)); } [Test] @@ -164,6 +168,23 @@ Assert.AreSame(expectedCalculation, calculation); } + [Test] + public void AssessmentLayerThree_ValueSet_ReturnExpectedValue() + { + // Setup + var random = new Random(21); + RoundedDouble assessmentLayerThree = random.NextRoundedDouble(); + + var sectionResult = new StabilityPointStructuresFailureMechanismSectionResult(CreateSection()); + var row = new StabilityPointStructuresFailureMechanismSectionResultRow(sectionResult); + + // Call + row.AssessmentLayerThree = assessmentLayerThree; + + // Assert + Assert.AreEqual(assessmentLayerThree, sectionResult.AssessmentLayerThree); + } + private static FailureMechanismSection CreateSection() { return new FailureMechanismSection("name", new[]