Index: Ringtoets/Common/src/Ringtoets.Common.Forms/Helpers/ProbabilityFormattingHelper.cs
===================================================================
diff -u -r5cb5707e72014afb2b2bc5a015bf3bd507242318 -re71b611930c2ed5cea2117df1fd1effd3d45f4f4
--- Ringtoets/Common/src/Ringtoets.Common.Forms/Helpers/ProbabilityFormattingHelper.cs (.../ProbabilityFormattingHelper.cs) (revision 5cb5707e72014afb2b2bc5a015bf3bd507242318)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/Helpers/ProbabilityFormattingHelper.cs (.../ProbabilityFormattingHelper.cs) (revision e71b611930c2ed5cea2117df1fd1effd3d45f4f4)
@@ -19,6 +19,7 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
+using System;
using Ringtoets.Common.Forms.Properties;
using CommonBaseResources = Core.Common.Base.Properties.Resources;
@@ -34,6 +35,7 @@
///
/// The probability.
/// The formatted text.
+ /// Thrown when the probability cannot be formatted as a string.
public static string Format(double probability)
{
if (probability.Equals(0.0))
@@ -50,6 +52,7 @@
///
/// The return period.
/// The formatted text.
+ /// Thrown when the return period cannot be formatted as a string.
public static string FormatFromReturnPeriod(int returnPeriod)
{
if (returnPeriod == 0)
Index: Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs
===================================================================
diff -u -r5cb5707e72014afb2b2bc5a015bf3bd507242318 -re71b611930c2ed5cea2117df1fd1effd3d45f4f4
--- Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision 5cb5707e72014afb2b2bc5a015bf3bd507242318)
+++ Ringtoets/Common/src/Ringtoets.Common.Forms/PropertyClasses/StructuresInputBaseProperties.cs (.../StructuresInputBaseProperties.cs) (revision e71b611930c2ed5cea2117df1fd1effd3d45f4f4)
@@ -518,7 +518,9 @@
{
get
{
- return data.WrappedData.ForeshoreProfile == null ? new UseBreakWaterProperties() : new UseBreakWaterProperties(data.WrappedData, PropertyChangeHandler);
+ return data.WrappedData.ForeshoreProfile == null
+ ? new UseBreakWaterProperties()
+ : new UseBreakWaterProperties(data.WrappedData, PropertyChangeHandler);
}
}
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Helpers/ProbabilityFormattingHelperTest.cs
===================================================================
diff -u -r5cb5707e72014afb2b2bc5a015bf3bd507242318 -re71b611930c2ed5cea2117df1fd1effd3d45f4f4
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Helpers/ProbabilityFormattingHelperTest.cs (.../ProbabilityFormattingHelperTest.cs) (revision 5cb5707e72014afb2b2bc5a015bf3bd507242318)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Helpers/ProbabilityFormattingHelperTest.cs (.../ProbabilityFormattingHelperTest.cs) (revision e71b611930c2ed5cea2117df1fd1effd3d45f4f4)
@@ -44,6 +44,8 @@
[TestCase(0.6, "1/2")]
[TestCase(0.0001, "1/10.000")]
[TestCase(0.000000123456789, "1/8.100.000")]
+ [TestCase(-0.0001, "1/-10.000")]
+ [TestCase(-0.5, "1/-2")]
public void Format_ProbabilityNotZero_ReturnOneOverReturnPeriod(double probability, string expectedText)
{
// Call
@@ -69,6 +71,8 @@
[TestCase(2, "1/2")]
[TestCase(10000, "1/10.000")]
[TestCase(8100000, "1/8.100.000")]
+ [TestCase(-1000, "1/-1.000")]
+ [TestCase(-2, "1/-2")]
public void FormatFromReturnPeriod_ReturnPeriodNotZero_ReturnOneOverReturnPeriod(int returnPeriod, string expectedText)
{
// Call
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs
===================================================================
diff -u -r5cb5707e72014afb2b2bc5a015bf3bd507242318 -re71b611930c2ed5cea2117df1fd1effd3d45f4f4
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision 5cb5707e72014afb2b2bc5a015bf3bd507242318)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/StructuresInputBasePropertiesTest.cs (.../StructuresInputBasePropertiesTest.cs) (revision e71b611930c2ed5cea2117df1fd1effd3d45f4f4)
@@ -87,7 +87,12 @@
// Setup
mockRepository.ReplayAll();
- StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties constructionProperties = GetRandomConstructionProperties();
+ StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties constructionProperties = GetRandomConstructionProperties();
// Call
TestDelegate call = () => new SimpleStructuresInputProperties(null, constructionProperties, handler);
@@ -102,7 +107,12 @@
public void Constructor_ChangeHandlerIsNull_ThrowsArgumentNullException()
{
// Setup
- StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties constructionProperties = GetRandomConstructionProperties();
+ StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties constructionProperties = GetRandomConstructionProperties();
var calculation = new StructuresCalculation();
var inputContext = new SimpleInputContext(calculation.InputParameters,
calculation,
@@ -123,7 +133,12 @@
// Setup
mockRepository.ReplayAll();
- StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties constructionProperties = GetRandomConstructionProperties();
+ StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties constructionProperties = GetRandomConstructionProperties();
var calculation = new StructuresCalculation();
var inputContext = new SimpleInputContext(calculation.InputParameters,
calculation,
@@ -278,7 +293,12 @@
// Setup
mockRepository.ReplayAll();
- StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties constructionProperties = GetRandomConstructionProperties();
+ StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties constructionProperties = GetRandomConstructionProperties();
var calculation = new StructuresCalculation();
var inputContext = new SimpleInputContext(calculation.InputParameters,
calculation,
@@ -324,7 +344,12 @@
assessmentSection);
var properties = new SimpleStructuresInputProperties(
inputContext,
- new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties(),
+ new StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties(),
handler);
SelectableHydraulicBoundaryLocation selectedHydraulicBoundaryLocation = null;
@@ -367,7 +392,12 @@
var properties = new SimpleStructuresInputProperties(
inputContext,
- new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties(),
+ new StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties(),
handler);
// Call
@@ -411,7 +441,12 @@
var properties = new SimpleStructuresInputProperties(
inputContext,
- new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties(),
+ new StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties(),
handler);
// Call
@@ -461,7 +496,12 @@
var properties = new SimpleStructuresInputProperties(
inputContext,
- new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties(),
+ new StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties(),
handler);
// When
@@ -502,7 +542,12 @@
assessmentSection);
var properties = new SimpleStructuresInputProperties(
inputContext,
- new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties(),
+ new StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties(),
handler);
// Call
@@ -550,7 +595,12 @@
assessmentSection);
var properties = new SimpleStructuresInputProperties(
inputContext,
- new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties(),
+ new StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties(),
handler);
// Call
@@ -607,7 +657,12 @@
var properties = new SimpleStructuresInputProperties(
inputContext,
- new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties(),
+ new StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties(),
customHandler);
IEnumerable originalList = properties.GetSelectableHydraulicBoundaryLocations()
@@ -657,7 +712,12 @@
var properties = new SimpleStructuresInputProperties(
inputContext,
- new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties(),
+ new StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties(),
new ObservablePropertyChangeHandler(inputContext.Calculation, calculation.InputParameters));
inputContext.Attach(observer);
@@ -817,7 +877,12 @@
var properties = new SimpleStructuresInputProperties(
inputContext,
- new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties(),
+ new StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties(),
customHandler);
// Precondition
@@ -848,7 +913,12 @@
var properties = new SimpleStructuresInputProperties(
inputContext,
- new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties(),
+ new StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties(),
customHandler);
// Precondition
@@ -866,7 +936,12 @@
return new SetPropertyValueAfterConfirmationParameterTester(Enumerable.Empty());
}
- private static StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties
+ private static StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties
GetRandomConstructionProperties()
{
var structureObject = new object();
@@ -906,7 +981,12 @@
}.OrderBy(p => random.Next())
.ToList();
- return new StructuresInputBaseProperties, IFailureMechanism>.ConstructionProperties
+ return new StructuresInputBaseProperties<
+ TestStructure,
+ SimpleStructureInput,
+ StructuresCalculation,
+ IFailureMechanism>
+ .ConstructionProperties
{
StructurePropertyIndex = randomObjectLookup.IndexOf(structureObject),
StructureLocationPropertyIndex = randomObjectLookup.IndexOf(structureLocationObject),
Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TypeConverters/NoProbabilityValueDoubleConverterTest.cs
===================================================================
diff -u -r5cb5707e72014afb2b2bc5a015bf3bd507242318 -re71b611930c2ed5cea2117df1fd1effd3d45f4f4
--- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TypeConverters/NoProbabilityValueDoubleConverterTest.cs (.../NoProbabilityValueDoubleConverterTest.cs) (revision 5cb5707e72014afb2b2bc5a015bf3bd507242318)
+++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/TypeConverters/NoProbabilityValueDoubleConverterTest.cs (.../NoProbabilityValueDoubleConverterTest.cs) (revision e71b611930c2ed5cea2117df1fd1effd3d45f4f4)
@@ -122,19 +122,25 @@
[TestCase("1/2,500", 0.4)]
[TestCase("1/2.500", 0.0004)]
[TestCase("1e-3", 0.001)]
+ [TestCase("1/1.000", 0.001)]
+ [TestCase("1/0", double.PositiveInfinity)]
+ [TestCase("1/-1.000", -0.001)]
+ [TestCase("1/-10", -0.1)]
+ [TestCase("1/-2,5", -0.4)]
+ [TestCase("-0,5", -0.5)]
+ [TestCase("-1", -1.0)]
+ [TestCase("-1e-2", -0.01)]
public void ConvertFrom_StringInDutchCulture_ReturnExpectedConvertedDouble(string input, double expectedOutput)
{
// Setup
var mocks = new MockRepository();
var context = mocks.Stub();
mocks.ReplayAll();
- string text = input.ToString(CultureInfo.CurrentCulture);
-
var converter = new NoProbabilityValueDoubleConverter();
// Call
- var conversionResult = (double) converter.ConvertFrom(context, CultureInfo.CurrentCulture, text);
+ var conversionResult = (double) converter.ConvertFrom(context, CultureInfo.CurrentCulture, input);
// Assert
Assert.AreEqual(expectedOutput, conversionResult);
@@ -146,19 +152,25 @@
[TestCase("1/25", 0.04)]
[TestCase("1/2.5", 0.4)]
[TestCase("1e-3", 0.001)]
+ [TestCase("1/1,000", 0.001)]
+ [TestCase("1/0", double.PositiveInfinity)]
+ [TestCase("1/-1,000", -0.001)]
+ [TestCase("1/-10", -0.1)]
+ [TestCase("1/-2.5", -0.4)]
+ [TestCase("-0.5", -0.5)]
+ [TestCase("-1", -1.0)]
+ [TestCase("-1e-2", -0.01)]
public void ConvertFrom_StringInEnglishCulture_ReturnExpectedConvertedDouble(string input, double expectedOutput)
{
// Setup
var mocks = new MockRepository();
var context = mocks.Stub();
mocks.ReplayAll();
- string text = input.ToString(CultureInfo.CurrentCulture);
-
var converter = new NoProbabilityValueDoubleConverter();
// Call
- var conversionResult = (double) converter.ConvertFrom(context, CultureInfo.CurrentCulture, text);
+ var conversionResult = (double) converter.ConvertFrom(context, CultureInfo.CurrentCulture, input);
// Assert
Assert.AreEqual(expectedOutput, conversionResult);