Index: Ringtoets/Common/src/Ringtoets.Common.IO/ReadBreakWaterType.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.IO/ReadBreakWaterType.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/ReadBreakWaterType.cs (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
@@ -0,0 +1,44 @@
+// 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.
+
+namespace Ringtoets.Common.IO
+{
+ ///
+ /// Defines the various types of break water values possible in a read calculation configuration.
+ ///
+ public enum ReadBreakWaterType
+ {
+ ///
+ /// A wall.
+ ///
+ Wall = 1,
+
+ ///
+ /// A watertight retaining structure.
+ ///
+ Caisson = 2,
+
+ ///
+ /// A barrier that impounds water or underground streams.
+ ///
+ Dam = 3
+ }
+}
\ No newline at end of file
Index: Ringtoets/Common/src/Ringtoets.Common.IO/ReadBreakWaterTypeConverter.cs
===================================================================
diff -u
--- Ringtoets/Common/src/Ringtoets.Common.IO/ReadBreakWaterTypeConverter.cs (revision 0)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/ReadBreakWaterTypeConverter.cs (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
@@ -0,0 +1,81 @@
+// 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.ComponentModel;
+using System.Globalization;
+using Ringtoets.Common.IO.Schema;
+
+namespace Ringtoets.Common.IO
+{
+ ///
+ /// Converts to and back.
+ ///
+ public class ReadBreakWaterTypeConverter : TypeConverter
+ {
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == typeof(string))
+ {
+ var type = (ReadBreakWaterType) value;
+ switch (type)
+ {
+ case ReadBreakWaterType.Caisson:
+ return ConfigurationSchemaIdentifiers.BreakWaterCaisson;
+ case ReadBreakWaterType.Dam:
+ return ConfigurationSchemaIdentifiers.BreakWaterDam;
+ case ReadBreakWaterType.Wall:
+ return ConfigurationSchemaIdentifiers.BreakWaterWall;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ if (sourceType == typeof(string))
+ {
+ return true;
+ }
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ var text = value as string;
+ if (text != null)
+ {
+ switch (text)
+ {
+ case ConfigurationSchemaIdentifiers.BreakWaterCaisson:
+ return ReadBreakWaterType.Caisson;
+ case ConfigurationSchemaIdentifiers.BreakWaterDam:
+ return ReadBreakWaterType.Dam;
+ case ConfigurationSchemaIdentifiers.BreakWaterWall:
+ return ReadBreakWaterType.Wall;
+ }
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 56daaecf144ac21035cad0977ae4c2c8294449c0 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.IO/Readers/ReadBreakWaterType.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 56daaecf144ac21035cad0977ae4c2c8294449c0 refers to a dead (removed) revision in file `Ringtoets/Common/src/Ringtoets.Common.IO/Readers/ReadBreakWaterTypeConverter.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj
===================================================================
diff -u -r69c1988e3c492c44148e112151efb3c04a853fcc -r56daaecf144ac21035cad0977ae4c2c8294449c0
--- Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 69c1988e3c492c44148e112151efb3c04a853fcc)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Ringtoets.Common.IO.csproj (.../Ringtoets.Common.IO.csproj) (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
@@ -54,7 +54,7 @@
-
+
@@ -83,7 +83,7 @@
-
+
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReadBreakWaterTypeConverterTest.cs
===================================================================
diff -u
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReadBreakWaterTypeConverterTest.cs (revision 0)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/ReadBreakWaterTypeConverterTest.cs (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
@@ -0,0 +1,155 @@
+// 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.ComponentModel;
+using NUnit.Framework;
+using Ringtoets.Common.IO.Schema;
+
+namespace Ringtoets.Common.IO.Test
+{
+ [TestFixture]
+ public class ReadBreakWaterTypeConverterTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var converter = new ReadBreakWaterTypeConverter();
+
+ // Assert
+ Assert.IsInstanceOf(converter);
+ }
+
+ [Test]
+ public void CanConvertTo_String_ReturnTrue()
+ {
+ // Setup
+ var converter = new ReadBreakWaterTypeConverter();
+
+ // Call
+ bool canConvertToString = converter.CanConvertTo(typeof(string));
+
+ // Assert
+ Assert.IsTrue(canConvertToString);
+ }
+
+ [Test]
+ public void CanConvertTo_OtherThanString_ReturnFalse()
+ {
+ // Setup
+ var converter = new ReadBreakWaterTypeConverter();
+
+ // Call
+ bool canConvertToString = converter.CanConvertTo(typeof(object));
+
+ // Assert
+ Assert.IsFalse(canConvertToString);
+ }
+
+ [Test]
+ [TestCase(ReadBreakWaterType.Caisson, ConfigurationSchemaIdentifiers.BreakWaterCaisson)]
+ [TestCase(ReadBreakWaterType.Dam, ConfigurationSchemaIdentifiers.BreakWaterDam)]
+ [TestCase(ReadBreakWaterType.Wall, ConfigurationSchemaIdentifiers.BreakWaterWall)]
+ public void ConverTo_VariousCases_ReturnExpectedText(ReadBreakWaterType value,
+ string expectedResult)
+ {
+ // Setup
+ var converter = new ReadBreakWaterTypeConverter();
+
+ // Call
+ object result = converter.ConvertTo(value, typeof(string));
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ [Test]
+ public void ConvertTo_InvalidBreakWaterType_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new ReadBreakWaterTypeConverter();
+ var invalidValue = (ReadBreakWaterType) 99999999;
+
+ // Call
+ TestDelegate call = () => converter.ConvertTo(invalidValue, typeof(string));
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ public void CanConvertFrom_String_ReturnTrue()
+ {
+ // Setup
+ var converter = new ReadBreakWaterTypeConverter();
+
+ // Call
+ bool canConvertFromString = converter.CanConvertFrom(typeof(string));
+
+ // Assert
+ Assert.IsTrue(canConvertFromString);
+ }
+
+ [Test]
+ public void CanConvertFrom_OtherThanString_ReturnFalse()
+ {
+ // Setup
+ var converter = new ReadBreakWaterTypeConverter();
+
+ // Call
+ bool canConvertFromString = converter.CanConvertFrom(typeof(object));
+
+ // Assert
+ Assert.IsFalse(canConvertFromString);
+ }
+
+ [Test]
+ [TestCase(ConfigurationSchemaIdentifiers.BreakWaterCaisson, ReadBreakWaterType.Caisson)]
+ [TestCase(ConfigurationSchemaIdentifiers.BreakWaterDam, ReadBreakWaterType.Dam)]
+ [TestCase(ConfigurationSchemaIdentifiers.BreakWaterWall, ReadBreakWaterType.Wall)]
+ public void ConvertFrom_Text_ReturnExpectedBreakWaterType(string value,
+ ReadBreakWaterType expectedResult)
+ {
+ // Setup
+ var converter = new ReadBreakWaterTypeConverter();
+
+ // Call
+ object result = converter.ConvertFrom(value);
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ [Test]
+ public void ConvertFrom_InvalidText_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new ReadBreakWaterTypeConverter();
+
+ // Call
+ TestDelegate call = () => converter.ConvertFrom("A");
+
+ // Assert
+ Assert.Throws(call);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 56daaecf144ac21035cad0977ae4c2c8294449c0 refers to a dead (removed) revision in file `Ringtoets/Common/test/Ringtoets.Common.IO.Test/Readers/ReadBreakWaterTypeConverterTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj
===================================================================
diff -u -r53c9fa4450ca27bd61c3bec0c980b2737aaf455d -r56daaecf144ac21035cad0977ae4c2c8294449c0
--- Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 53c9fa4450ca27bd61c3bec0c980b2737aaf455d)
+++ Ringtoets/Common/test/Ringtoets.Common.IO.Test/Ringtoets.Common.IO.Test.csproj (.../Ringtoets.Common.IO.Test.csproj) (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
@@ -59,7 +59,7 @@
-
+
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/ReadDikeHeightCalculationType.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/ReadDikeHeightCalculationType.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/ReadDikeHeightCalculationType.cs (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
@@ -0,0 +1,44 @@
+// 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.
+
+namespace Ringtoets.GrassCoverErosionInwards.IO
+{
+ ///
+ /// Defines the various types of dike height calculations in a read calculation configuration.
+ ///
+ public enum ReadDikeHeightCalculationType
+ {
+ ///
+ /// No calculation.
+ ///
+ NoCalculation = 1,
+
+ ///
+ /// Calculate by using the norm on assessment section.
+ ///
+ CalculateByAssessmentSectionNorm = 2,
+
+ ///
+ /// Calculate using the probability of the specific profile.
+ ///
+ CalculateByProfileSpecificRequiredProbability = 3
+ }
+}
\ No newline at end of file
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/ReadDikeHeightCalculationTypeConverter.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/ReadDikeHeightCalculationTypeConverter.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/ReadDikeHeightCalculationTypeConverter.cs (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
@@ -0,0 +1,84 @@
+// 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.ComponentModel;
+using System.Globalization;
+using Ringtoets.GrassCoverErosionInwards.IO.Properties;
+
+namespace Ringtoets.GrassCoverErosionInwards.IO
+{
+ ///
+ /// Converts to and back.
+ ///
+ public class ReadDikeHeightCalculationTypeConverter : TypeConverter
+ {
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == typeof(string))
+ {
+ var readDikeHeightCalculationType = (ReadDikeHeightCalculationType) value;
+ switch (readDikeHeightCalculationType)
+ {
+ case ReadDikeHeightCalculationType.NoCalculation:
+ return Resources.ReadDikeHeightCalculationTypeConverter_NoCalculation;
+ case ReadDikeHeightCalculationType.CalculateByAssessmentSectionNorm:
+ return Resources.ReadDikeHeightCalculationTypeConverter_CalculateByAssessmentSectionNorm;
+ case ReadDikeHeightCalculationType.CalculateByProfileSpecificRequiredProbability:
+ return Resources.ReadDikeHeightCalculationTypeConverter_CalculateByProfileSpecificRequiredProbability;
+ default:
+ throw new NotSupportedException();
+ }
+ }
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ if (sourceType == typeof(string))
+ {
+ return true;
+ }
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ var text = value as string;
+ if (text != null)
+ {
+ if (text == Resources.ReadDikeHeightCalculationTypeConverter_NoCalculation)
+ {
+ return ReadDikeHeightCalculationType.NoCalculation;
+ }
+ if (text == Resources.ReadDikeHeightCalculationTypeConverter_CalculateByAssessmentSectionNorm)
+ {
+ return ReadDikeHeightCalculationType.CalculateByAssessmentSectionNorm;
+ }
+ if (text == Resources.ReadDikeHeightCalculationTypeConverter_CalculateByProfileSpecificRequiredProbability)
+ {
+ return ReadDikeHeightCalculationType.CalculateByProfileSpecificRequiredProbability;
+ }
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 56daaecf144ac21035cad0977ae4c2c8294449c0 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Readers/ReadDikeHeightCalculationType.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 56daaecf144ac21035cad0977ae4c2c8294449c0 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Readers/ReadDikeHeightCalculationTypeConverter.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Ringtoets.GrassCoverErosionInwards.IO.csproj
===================================================================
diff -u -r69c1988e3c492c44148e112151efb3c04a853fcc -r56daaecf144ac21035cad0977ae4c2c8294449c0
--- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Ringtoets.GrassCoverErosionInwards.IO.csproj (.../Ringtoets.GrassCoverErosionInwards.IO.csproj) (revision 69c1988e3c492c44148e112151efb3c04a853fcc)
+++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Ringtoets.GrassCoverErosionInwards.IO.csproj (.../Ringtoets.GrassCoverErosionInwards.IO.csproj) (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
@@ -41,11 +41,11 @@
Properties\GlobalAssembly.cs
-
+
-
+
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/ReadDikeHeightCalculationConverterTest.cs
===================================================================
diff -u
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/ReadDikeHeightCalculationConverterTest.cs (revision 0)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/ReadDikeHeightCalculationConverterTest.cs (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
@@ -0,0 +1,166 @@
+// 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.ComponentModel;
+using NUnit.Framework;
+
+namespace Ringtoets.GrassCoverErosionInwards.IO.Test
+{
+ [TestFixture]
+ public class ReadDikeHeightCalculationConverterTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var converter = new ReadDikeHeightCalculationTypeConverter();
+
+ // Assert
+ Assert.IsInstanceOf(converter);
+ }
+
+ [Test]
+ public void CanConvertTo_String_ReturnTrue()
+ {
+ // Setup
+ var converter = new ReadDikeHeightCalculationTypeConverter();
+
+ // Call
+ bool canConvertToString = converter.CanConvertTo(typeof(string));
+
+ // Assert
+ Assert.IsTrue(canConvertToString);
+ }
+
+ [Test]
+ public void CanConvertTo_NotString_ReturnFalse()
+ {
+ // Setup
+ var converter = new ReadDikeHeightCalculationTypeConverter();
+
+ // Call
+ bool canConvert = converter.CanConvertTo(typeof(object));
+
+ // Assert
+ Assert.IsFalse(canConvert);
+ }
+
+ [Test]
+ [TestCase(ReadDikeHeightCalculationType.NoCalculation, "niet")]
+ [TestCase(ReadDikeHeightCalculationType.CalculateByAssessmentSectionNorm, "norm")]
+ [TestCase(ReadDikeHeightCalculationType.CalculateByProfileSpecificRequiredProbability, "doorsnede")]
+ public void ConvertTo_VariousCases_ReturnExpectedValues(ReadDikeHeightCalculationType value, string expectedResult)
+ {
+ // Setup
+ var converter = new ReadDikeHeightCalculationTypeConverter();
+
+ // Call
+ object result = converter.ConvertTo(value, typeof(string));
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ [Test]
+ public void ConvertTo_InvalidDikeHeightCalculationTypeValue_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new ReadDikeHeightCalculationTypeConverter();
+
+ var invalidValue = (ReadDikeHeightCalculationType) 9999999;
+
+ // Call
+ TestDelegate call = () => converter.ConvertTo(invalidValue, typeof(string));
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ public void ConvertTo_Object_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new ReadDikeHeightCalculationTypeConverter();
+
+ // Call
+ TestDelegate call = () => converter.ConvertTo(ReadDikeHeightCalculationType.NoCalculation, typeof(object));
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ public void CanConvertFrom_String_ReturnTrue()
+ {
+ // Setup
+ var converter = new ReadDikeHeightCalculationTypeConverter();
+
+ // Call
+ bool canConvertFromString = converter.CanConvertFrom(typeof(string));
+
+ // Assert
+ Assert.IsTrue(canConvertFromString);
+ }
+
+ [Test]
+ public void CanConvertFrom_NonString_ReturnFalse()
+ {
+ // Setup
+ var converter = new ReadDikeHeightCalculationTypeConverter();
+
+ // Call
+ bool canConvert = converter.CanConvertFrom(typeof(object));
+
+ // Assert
+ Assert.IsFalse(canConvert);
+ }
+
+ [Test]
+ [TestCase("niet", ReadDikeHeightCalculationType.NoCalculation)]
+ [TestCase("norm", ReadDikeHeightCalculationType.CalculateByAssessmentSectionNorm)]
+ [TestCase("doorsnede", ReadDikeHeightCalculationType.CalculateByProfileSpecificRequiredProbability)]
+ public void ConvertFrom_VariousCases_ReturnExpectedValue(string value, ReadDikeHeightCalculationType expectedResult)
+ {
+ // Setup
+ var converter = new ReadDikeHeightCalculationTypeConverter();
+
+ // Call
+ object result = converter.ConvertFrom(value);
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ [Test]
+ public void ConvertFrom_UnsupportedString_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new ReadDikeHeightCalculationTypeConverter();
+
+ // Call
+ TestDelegate call = () => converter.ConvertFrom("");
+
+ // Assert
+ Assert.Throws(call);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 56daaecf144ac21035cad0977ae4c2c8294449c0 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Readers/ReadDikeHeightCalculationConverterTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Ringtoets.GrassCoverErosionInwards.IO.Test.csproj
===================================================================
diff -u -r53c9fa4450ca27bd61c3bec0c980b2737aaf455d -r56daaecf144ac21035cad0977ae4c2c8294449c0
--- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Ringtoets.GrassCoverErosionInwards.IO.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.IO.Test.csproj) (revision 53c9fa4450ca27bd61c3bec0c980b2737aaf455d)
+++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Ringtoets.GrassCoverErosionInwards.IO.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.IO.Test.csproj) (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
@@ -54,7 +54,7 @@
-
+
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/ReadWaveConditionsInputStepSize.cs
===================================================================
diff -u
--- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/ReadWaveConditionsInputStepSize.cs (revision 0)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/ReadWaveConditionsInputStepSize.cs (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
@@ -0,0 +1,44 @@
+// 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.
+
+namespace Ringtoets.Revetment.IO
+{
+ ///
+ /// Enum defining the possible step size value in a read wave conditions calculation.
+ ///
+ public enum ReadWaveConditionsInputStepSize
+ {
+ ///
+ /// A step size of 0.5
+ ///
+ Half = 1,
+
+ ///
+ /// A step size of 1.0
+ ///
+ One = 2,
+
+ ///
+ /// A step size of 2.0
+ ///
+ Two = 3
+ }
+}
\ No newline at end of file
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/ReadWaveConditionsInputStepSizeConverter.cs
===================================================================
diff -u
--- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/ReadWaveConditionsInputStepSizeConverter.cs (revision 0)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/ReadWaveConditionsInputStepSizeConverter.cs (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
@@ -0,0 +1,86 @@
+// 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.ComponentModel;
+using System.Globalization;
+
+namespace Ringtoets.Revetment.IO
+{
+ ///
+ /// Converts to and back.
+ ///
+ public class ReadWaveConditionsInputStepSizeConverter : TypeConverter
+ {
+ public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
+ {
+ if (destinationType == typeof(string))
+ {
+ switch ((ReadWaveConditionsInputStepSize) value)
+ {
+ case ReadWaveConditionsInputStepSize.Half:
+ return FormatStepSizeValue(culture, 0.5);
+ case ReadWaveConditionsInputStepSize.One:
+ return FormatStepSizeValue(culture, 1.0);
+ case ReadWaveConditionsInputStepSize.Two:
+ return FormatStepSizeValue(culture, 2.0);
+ }
+ }
+ return base.ConvertTo(context, culture, value, destinationType);
+ }
+
+ public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
+ {
+ if (sourceType == typeof(string))
+ {
+ return true;
+ }
+ return base.CanConvertFrom(context, sourceType);
+ }
+
+ public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value)
+ {
+ var text = value as string;
+ if (text != null)
+ {
+ string decimalSeperator = culture.NumberFormat.NumberDecimalSeparator;
+ if ($"0{decimalSeperator}5".Equals(text))
+ {
+ return ReadWaveConditionsInputStepSize.Half;
+ }
+ if ($"1{decimalSeperator}0".Equals(text))
+ {
+ return ReadWaveConditionsInputStepSize.One;
+ }
+ if ($"2{decimalSeperator}0".Equals(text))
+ {
+ return ReadWaveConditionsInputStepSize.Two;
+ }
+ }
+ return base.ConvertFrom(context, culture, value);
+ }
+
+ private static string FormatStepSizeValue(CultureInfo culture, double stepSizeValue)
+ {
+ return string.Format(culture, "{0:0.0}", stepSizeValue);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 56daaecf144ac21035cad0977ae4c2c8294449c0 refers to a dead (removed) revision in file `Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/ReadWaveConditionsInputStepSize.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Fisheye: Tag 56daaecf144ac21035cad0977ae4c2c8294449c0 refers to a dead (removed) revision in file `Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Readers/ReadWaveConditionsInputStepSizeConverter.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Ringtoets.Revetment.IO.csproj
===================================================================
diff -u -r69c1988e3c492c44148e112151efb3c04a853fcc -r56daaecf144ac21035cad0977ae4c2c8294449c0
--- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Ringtoets.Revetment.IO.csproj (.../Ringtoets.Revetment.IO.csproj) (revision 69c1988e3c492c44148e112151efb3c04a853fcc)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/Ringtoets.Revetment.IO.csproj (.../Ringtoets.Revetment.IO.csproj) (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
@@ -56,12 +56,12 @@
Resources.resx
-
+
-
+
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/ReadWaveConditionsInputStepSizeTypeConverterTest.cs
===================================================================
diff -u
--- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/ReadWaveConditionsInputStepSizeTypeConverterTest.cs (revision 0)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/ReadWaveConditionsInputStepSizeTypeConverterTest.cs (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
@@ -0,0 +1,175 @@
+// 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.ComponentModel;
+using System.Globalization;
+using NUnit.Framework;
+
+namespace Ringtoets.Revetment.IO.Test
+{
+ [TestFixture]
+ public class ReadWaveConditionsInputStepSizeTypeConverterTest
+ {
+ [Test]
+ public void Constructor_ExpectedValues()
+ {
+ // Call
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Assert
+ Assert.IsInstanceOf(converter);
+ }
+
+ [Test]
+ public void CanConvertTo_String_ReturnTrue()
+ {
+ // Setup
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Call
+ bool canConvertToString = converter.CanConvertTo(typeof(string));
+
+ // Assert
+ Assert.IsTrue(canConvertToString);
+ }
+
+ [Test]
+ public void CanConvertTo_OtherTypeThenString_ReturnFalse()
+ {
+ // Setup
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Call
+ bool canConvertToNonString = converter.CanConvertTo(typeof(object));
+
+ // Assert
+ Assert.IsFalse(canConvertToNonString);
+ }
+
+ [Test]
+ [SetCulture("nl-NL")]
+ [TestCase(ReadWaveConditionsInputStepSize.Half, "0,5")]
+ [TestCase(ReadWaveConditionsInputStepSize.One, "1,0")]
+ [TestCase(ReadWaveConditionsInputStepSize.Two, "2,0")]
+ public void ConvertTo_ForAllEnumValues_ReturnExpectedText(ReadWaveConditionsInputStepSize value,
+ string expectedText)
+ {
+ // Setup
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Call
+ object result = converter.ConvertTo(null, CultureInfo.CurrentCulture, value, typeof(string));
+
+ // Assert
+ Assert.AreEqual(expectedText, result);
+ }
+
+ [Test]
+ public void ConvertTo_Object_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Call
+ TestDelegate call = () => converter.ConvertTo(ReadWaveConditionsInputStepSize.Half, typeof(object));
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ public void CanConvertFrom_String_ReturnTrue()
+ {
+ // Setup
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Call
+ bool canConvertFromString = converter.CanConvertFrom(typeof(string));
+
+ // Assert
+ Assert.IsTrue(canConvertFromString);
+ }
+
+ [Test]
+ public void CanConvertFrom_NonString_ReturnFalse()
+ {
+ // Setup
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Call
+ bool canConvertFromString = converter.CanConvertFrom(typeof(object));
+
+ // Assert
+ Assert.IsFalse(canConvertFromString);
+ }
+
+ [Test]
+ [SetCulture("nl-NL")]
+ [TestCase("0,5", ReadWaveConditionsInputStepSize.Half)]
+ [TestCase("1,0", ReadWaveConditionsInputStepSize.One)]
+ [TestCase("2,0", ReadWaveConditionsInputStepSize.Two)]
+ public void ConvertFrom_VariousCasesInCultureNL_ReturnWaveConditionsInputStepSize(string text,
+ ReadWaveConditionsInputStepSize expectedResult)
+ {
+ // Setup
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Call
+ object result = converter.ConvertFrom(null, CultureInfo.CurrentCulture, text);
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ [Test]
+ [SetCulture("en-US")]
+ [TestCase("0.5", ReadWaveConditionsInputStepSize.Half)]
+ [TestCase("1.0", ReadWaveConditionsInputStepSize.One)]
+ [TestCase("2.0", ReadWaveConditionsInputStepSize.Two)]
+ public void ConvertFrom_VariousCasesInCultureEN_ReturnWaveConditionsInputStepSize(string text,
+ ReadWaveConditionsInputStepSize expectedResult)
+ {
+ // Setup
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Call
+ object result = converter.ConvertFrom(null, CultureInfo.CurrentCulture, text);
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ [Test]
+ [SetCulture("nl-NL")]
+ public void ConvertFrom_InvalidText_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Call
+ TestDelegate call = () => converter.ConvertFrom("1");
+
+ // Assert
+ Assert.Throws(call);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 56daaecf144ac21035cad0977ae4c2c8294449c0 refers to a dead (removed) revision in file `Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Readers/ReadWaveConditionsInputStepSizeTypeConverterTest.cs'.
Fisheye: No comparison available. Pass `N' to diff?
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Ringtoets.Revetment.IO.Test.csproj
===================================================================
diff -u -r53c9fa4450ca27bd61c3bec0c980b2737aaf455d -r56daaecf144ac21035cad0977ae4c2c8294449c0
--- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Ringtoets.Revetment.IO.Test.csproj (.../Ringtoets.Revetment.IO.Test.csproj) (revision 53c9fa4450ca27bd61c3bec0c980b2737aaf455d)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Ringtoets.Revetment.IO.Test.csproj (.../Ringtoets.Revetment.IO.Test.csproj) (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
@@ -60,7 +60,7 @@
-
+