Index: Ringtoets/Revetment/src/Ringtoets.Revetment.IO/ReadWaveConditionsInputStepSizeConverter.cs
===================================================================
diff -u -re786dd8b8c7f833c217fdcddd909a616d590fe15 -r4d2320dbad8c743ec1c63e3a6509dd297ce710b8
--- Ringtoets/Revetment/src/Ringtoets.Revetment.IO/ReadWaveConditionsInputStepSizeConverter.cs (.../ReadWaveConditionsInputStepSizeConverter.cs) (revision e786dd8b8c7f833c217fdcddd909a616d590fe15)
+++ Ringtoets/Revetment/src/Ringtoets.Revetment.IO/ReadWaveConditionsInputStepSizeConverter.cs (.../ReadWaveConditionsInputStepSizeConverter.cs) (revision 4d2320dbad8c743ec1c63e3a6509dd297ce710b8)
@@ -49,10 +49,6 @@
public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType)
{
- if (sourceType == typeof(string))
- {
- return true;
- }
if (sourceType == typeof(double?))
{
return true;
@@ -62,24 +58,6 @@
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;
- }
- }
-
var doubleValue = value as double?;
if (doubleValue != null)
{
Index: Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/ReadWaveConditionsInputStepSizeConverterTest.cs
===================================================================
diff -u
--- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/ReadWaveConditionsInputStepSizeConverterTest.cs (revision 0)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/ReadWaveConditionsInputStepSizeConverterTest.cs (revision 4d2320dbad8c743ec1c63e3a6509dd297ce710b8)
@@ -0,0 +1,187 @@
+// 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 ReadWaveConditionsInputStepSizeConverterTest
+ {
+ [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_OtherTypeThanString_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_NullableDouble_ReturnTrue()
+ {
+ // Setup
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Call
+ bool canConvertFromNullableDouble = converter.CanConvertFrom(typeof(double?));
+
+ // Assert
+ Assert.IsTrue(canConvertFromNullableDouble);
+ }
+
+ [Test]
+ public void CanConvertFrom_NonNullableDouble_ReturnFalse()
+ {
+ // Setup
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Call
+ bool canConvertFromString = converter.CanConvertFrom(typeof(object));
+
+ // Assert
+ Assert.IsFalse(canConvertFromString);
+ }
+
+ [Test]
+ [TestCase(0.5, ReadWaveConditionsInputStepSize.Half)]
+ [TestCase(1, ReadWaveConditionsInputStepSize.One)]
+ [TestCase(2, ReadWaveConditionsInputStepSize.Two)]
+ public void ConvertFrom_VariousDoubles_ReturnWaveConditionsInputStepSize(double value,
+ ReadWaveConditionsInputStepSize expectedResult)
+ {
+ // Setup
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Call
+ object result = converter.ConvertFrom(null, CultureInfo.CurrentCulture, value);
+
+ // Assert
+ Assert.AreEqual(expectedResult, result);
+ }
+
+ [Test]
+ [SetCulture("nl-NL")]
+ public void ConvertFrom_InvalidText_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Call
+ TestDelegate call = () => converter.ConvertFrom("1x");
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ [TestCase(2.001)]
+ [TestCase(double.PositiveInfinity)]
+ [TestCase(double.NegativeInfinity)]
+ [TestCase(double.NaN)]
+ [TestCase(-0.5)]
+ public void ConvertFrom_InvalidDoubleValue_ThrowNotSupportedException(double value)
+ {
+ // Setup
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Call
+ TestDelegate call = () => converter.ConvertFrom(value);
+
+ // Assert
+ Assert.Throws(call);
+ }
+
+ [Test]
+ public void ConvertFrom_Null_ThrowNotSupportedException()
+ {
+ // Setup
+ var converter = new ReadWaveConditionsInputStepSizeConverter();
+
+ // Call
+ TestDelegate call = () => converter.ConvertFrom(null);
+
+ // Assert
+ Assert.Throws(call);
+ }
+ }
+}
\ No newline at end of file
Fisheye: Tag 4d2320dbad8c743ec1c63e3a6509dd297ce710b8 refers to a dead (removed) revision in file `Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/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 -r56daaecf144ac21035cad0977ae4c2c8294449c0 -r4d2320dbad8c743ec1c63e3a6509dd297ce710b8
--- Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Ringtoets.Revetment.IO.Test.csproj (.../Ringtoets.Revetment.IO.Test.csproj) (revision 56daaecf144ac21035cad0977ae4c2c8294449c0)
+++ Ringtoets/Revetment/test/Ringtoets.Revetment.IO.Test/Ringtoets.Revetment.IO.Test.csproj (.../Ringtoets.Revetment.IO.Test.csproj) (revision 4d2320dbad8c743ec1c63e3a6509dd297ce710b8)
@@ -60,7 +60,7 @@
-
+