Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/ConfigurationHydraulicLoadsCalculationType.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/ConfigurationHydraulicLoadsCalculationType.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/ConfigurationHydraulicLoadsCalculationType.cs (revision 8336ede0837d35257e8b85c3b0090b0774342d90) @@ -0,0 +1,44 @@ +// 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. + +namespace Ringtoets.GrassCoverErosionInwards.IO.Configurations +{ + /// + /// Defines the various types of hydraulic loads calculations in a read calculation configuration. + /// + public enum ConfigurationHydraulicLoadsCalculationType + { + /// + /// 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/Configurations/GrassCoverErosionInwardsCalculationConfiguration.cs =================================================================== diff -u -r237b9031d74382e26141395ff845d5e43f44981d -r8336ede0837d35257e8b85c3b0090b0774342d90 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfiguration.cs (.../GrassCoverErosionInwardsCalculationConfiguration.cs) (revision 237b9031d74382e26141395ff845d5e43f44981d) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfiguration.cs (.../GrassCoverErosionInwardsCalculationConfiguration.cs) (revision 8336ede0837d35257e8b85c3b0090b0774342d90) @@ -25,8 +25,7 @@ namespace Ringtoets.GrassCoverErosionInwards.IO.Configurations { /// - /// Class that represents a grass cover erosion inwards calculation that is read via - /// . + /// Configuration of a grass cover erosion inwards calculation. /// public class ReadGrassCoverErosionInwardsCalculation : IConfigurationItem { @@ -84,13 +83,13 @@ /// Gets the value for how the dike height should be calculated for the grass cover /// erosion inwards calculation. /// - public ReadHydraulicLoadsCalculationType? DikeHeightCalculationType { get; } + public ConfigurationHydraulicLoadsCalculationType? DikeHeightCalculationType { get; } /// /// Gets the value for how the overtopping rate should be calculated for the grass cover /// erosion inwards calculation. /// - public ReadHydraulicLoadsCalculationType? OvertoppingRateCalculationType { get; } + public ConfigurationHydraulicLoadsCalculationType? OvertoppingRateCalculationType { get; } /// /// Gets the value indicating if the break water for the grass cover erosion inwards @@ -161,12 +160,12 @@ /// /// Gets or sets the value for . /// - public ReadHydraulicLoadsCalculationType? DikeHeightCalculationType { get; set; } + public ConfigurationHydraulicLoadsCalculationType? DikeHeightCalculationType { get; set; } /// /// Gets or sets the value for . /// - public ReadHydraulicLoadsCalculationType? OvertoppingRateCalculationType { get; set; } + public ConfigurationHydraulicLoadsCalculationType? OvertoppingRateCalculationType { get; set; } /// /// Gets or sets the value for . Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfigurationReader.cs =================================================================== diff -u -r237b9031d74382e26141395ff845d5e43f44981d -r8336ede0837d35257e8b85c3b0090b0774342d90 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfigurationReader.cs (.../GrassCoverErosionInwardsCalculationConfigurationReader.cs) (revision 237b9031d74382e26141395ff845d5e43f44981d) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfigurationReader.cs (.../GrassCoverErosionInwardsCalculationConfigurationReader.cs) (revision 8336ede0837d35257e8b85c3b0090b0774342d90) @@ -26,6 +26,7 @@ using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Configurations.Helpers; using Ringtoets.Common.IO.Configurations.Import; +using Ringtoets.GrassCoverErosionInwards.IO.Configurations.Helpers; using Ringtoets.GrassCoverErosionInwards.IO.Properties; using RingtoetsCommonIOResources = Ringtoets.Common.IO.Properties.Resources; @@ -88,9 +89,9 @@ DikeProfileId = calculationElement.GetStringValueFromDescendantElement(GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.DikeProfileElement), Orientation = calculationElement.GetDoubleValueFromDescendantElement(ConfigurationSchemaIdentifiers.Orientation), DikeHeight = calculationElement.GetDoubleValueFromDescendantElement(GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.DikeHeightElement), - DikeHeightCalculationType = (ReadHydraulicLoadsCalculationType?) calculationElement.GetConvertedValueFromDescendantStringElement( + DikeHeightCalculationType = (ConfigurationHydraulicLoadsCalculationType?) calculationElement.GetConvertedValueFromDescendantStringElement( GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.DikeHeightCalculationTypeElement), - OvertoppingRateCalculationType = (ReadHydraulicLoadsCalculationType?) calculationElement.GetConvertedValueFromDescendantStringElement( + OvertoppingRateCalculationType = (ConfigurationHydraulicLoadsCalculationType?) calculationElement.GetConvertedValueFromDescendantStringElement( GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.OvertoppingRateCalculationTypeElement), UseBreakWater = calculationElement.GetBoolValueFromDescendantElement(ConfigurationSchemaIdentifiers.UseBreakWater), BreakWaterType = (ConfigurationBreakWaterType?) calculationElement.GetConvertedValueFromDescendantStringElement(ConfigurationSchemaIdentifiers.BreakWaterType), Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfigurationWriter.cs =================================================================== diff -u -r237b9031d74382e26141395ff845d5e43f44981d -r8336ede0837d35257e8b85c3b0090b0774342d90 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfigurationWriter.cs (.../GrassCoverErosionInwardsCalculationConfigurationWriter.cs) (revision 237b9031d74382e26141395ff845d5e43f44981d) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/GrassCoverErosionInwardsCalculationConfigurationWriter.cs (.../GrassCoverErosionInwardsCalculationConfigurationWriter.cs) (revision 8336ede0837d35257e8b85c3b0090b0774342d90) @@ -25,6 +25,7 @@ using Ringtoets.Common.IO.Configurations; using Ringtoets.Common.IO.Configurations.Export; using Ringtoets.GrassCoverErosionInwards.Data; +using Ringtoets.GrassCoverErosionInwards.IO.Configurations.Helpers; namespace Ringtoets.GrassCoverErosionInwards.IO.Configurations { @@ -50,11 +51,11 @@ writer.WriteElementString( GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.DikeHeightCalculationTypeElement, - HydraulicLoadsCalculationTypeAsXmlString((ReadHydraulicLoadsCalculationType) input.DikeHeightCalculationType)); + HydraulicLoadsCalculationTypeAsXmlString((ConfigurationHydraulicLoadsCalculationType) input.DikeHeightCalculationType)); writer.WriteElementString( GrassCoverErosionInwardsCalculationConfigurationSchemaIdentifiers.OvertoppingRateCalculationTypeElement, - HydraulicLoadsCalculationTypeAsXmlString((ReadHydraulicLoadsCalculationType) input.OvertoppingRateCalculationType)); + HydraulicLoadsCalculationTypeAsXmlString((ConfigurationHydraulicLoadsCalculationType) input.OvertoppingRateCalculationType)); WriteWaveReduction(input, writer); @@ -111,9 +112,9 @@ XmlConvert.ToString(input.DikeHeight)); } - private static string HydraulicLoadsCalculationTypeAsXmlString(ReadHydraulicLoadsCalculationType type) + private static string HydraulicLoadsCalculationTypeAsXmlString(ConfigurationHydraulicLoadsCalculationType type) { - return new ReadHydraulicLoadsCalculationTypeConverter().ConvertToInvariantString(type); + return new ConfigurationHydraulicLoadsCalculationTypeConverter().ConvertToInvariantString(type); } private static void WriteWaveReduction(GrassCoverErosionInwardsInput input, XmlWriter writer) Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/Helpers/ConfigurationHydraulicLoadsCalculationTypeConverter.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/Helpers/ConfigurationHydraulicLoadsCalculationTypeConverter.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Configurations/Helpers/ConfigurationHydraulicLoadsCalculationTypeConverter.cs (revision 8336ede0837d35257e8b85c3b0090b0774342d90) @@ -0,0 +1,84 @@ +// 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 Ringtoets.GrassCoverErosionInwards.IO.Properties; + +namespace Ringtoets.GrassCoverErosionInwards.IO.Configurations.Helpers +{ + /// + /// Converts to and back. + /// + public class ConfigurationHydraulicLoadsCalculationTypeConverter : TypeConverter + { + public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) + { + if (destinationType == typeof(string)) + { + var readHydraulicLoadsCalculationType = (ConfigurationHydraulicLoadsCalculationType) value; + switch (readHydraulicLoadsCalculationType) + { + case ConfigurationHydraulicLoadsCalculationType.NoCalculation: + return Resources.ReadHydraulicLoadsCalculationTypeConverter_NoCalculation; + case ConfigurationHydraulicLoadsCalculationType.CalculateByAssessmentSectionNorm: + return Resources.ReadHydraulicLoadsCalculationTypeConverter_CalculateByAssessmentSectionNorm; + case ConfigurationHydraulicLoadsCalculationType.CalculateByProfileSpecificRequiredProbability: + return Resources.ReadHydraulicLoadsCalculationTypeConverter_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.ReadHydraulicLoadsCalculationTypeConverter_NoCalculation) + { + return ConfigurationHydraulicLoadsCalculationType.NoCalculation; + } + if (text == Resources.ReadHydraulicLoadsCalculationTypeConverter_CalculateByAssessmentSectionNorm) + { + return ConfigurationHydraulicLoadsCalculationType.CalculateByAssessmentSectionNorm; + } + if (text == Resources.ReadHydraulicLoadsCalculationTypeConverter_CalculateByProfileSpecificRequiredProbability) + { + return ConfigurationHydraulicLoadsCalculationType.CalculateByProfileSpecificRequiredProbability; + } + } + return base.ConvertFrom(context, culture, value); + } + } +} \ No newline at end of file Fisheye: Tag 8336ede0837d35257e8b85c3b0090b0774342d90 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/ReadHydraulicLoadsCalculationType.cs'. Fisheye: No comparison available. Pass `N' to diff? Fisheye: Tag 8336ede0837d35257e8b85c3b0090b0774342d90 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/ReadHydraulicLoadsCalculationTypeConverter.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Ringtoets.GrassCoverErosionInwards.IO.csproj =================================================================== diff -u -r237b9031d74382e26141395ff845d5e43f44981d -r8336ede0837d35257e8b85c3b0090b0774342d90 --- Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Ringtoets.GrassCoverErosionInwards.IO.csproj (.../Ringtoets.GrassCoverErosionInwards.IO.csproj) (revision 237b9031d74382e26141395ff845d5e43f44981d) +++ Ringtoets/GrassCoverErosionInwards/src/Ringtoets.GrassCoverErosionInwards.IO/Ringtoets.GrassCoverErosionInwards.IO.csproj (.../Ringtoets.GrassCoverErosionInwards.IO.csproj) (revision 8336ede0837d35257e8b85c3b0090b0774342d90) @@ -45,11 +45,11 @@ Properties\GlobalAssembly.cs - + - + Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/GrassCoverErosionInwardsCalculationConfigurationReaderTest.cs =================================================================== diff -u -r237b9031d74382e26141395ff845d5e43f44981d -r8336ede0837d35257e8b85c3b0090b0774342d90 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/GrassCoverErosionInwardsCalculationConfigurationReaderTest.cs (.../GrassCoverErosionInwardsCalculationConfigurationReaderTest.cs) (revision 237b9031d74382e26141395ff845d5e43f44981d) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/GrassCoverErosionInwardsCalculationConfigurationReaderTest.cs (.../GrassCoverErosionInwardsCalculationConfigurationReaderTest.cs) (revision 8336ede0837d35257e8b85c3b0090b0774342d90) @@ -325,8 +325,8 @@ Assert.AreEqual("some_dike_profile", calculation.DikeProfileId); Assert.AreEqual(67.1, calculation.Orientation); Assert.AreEqual(3.45, calculation.DikeHeight); - Assert.AreEqual(ReadHydraulicLoadsCalculationType.CalculateByAssessmentSectionNorm, calculation.DikeHeightCalculationType); - Assert.AreEqual(ReadHydraulicLoadsCalculationType.CalculateByProfileSpecificRequiredProbability, calculation.OvertoppingRateCalculationType); + Assert.AreEqual(ConfigurationHydraulicLoadsCalculationType.CalculateByAssessmentSectionNorm, calculation.DikeHeightCalculationType); + Assert.AreEqual(ConfigurationHydraulicLoadsCalculationType.CalculateByProfileSpecificRequiredProbability, calculation.OvertoppingRateCalculationType); Assert.AreEqual(true, calculation.UseBreakWater); Assert.AreEqual(ConfigurationBreakWaterType.Dam, calculation.BreakWaterType); Assert.AreEqual(1.234, calculation.BreakWaterHeight); Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/GrassCoverErosionInwardsCalculationConfigurationTest.cs =================================================================== diff -u -r237b9031d74382e26141395ff845d5e43f44981d -r8336ede0837d35257e8b85c3b0090b0774342d90 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/GrassCoverErosionInwardsCalculationConfigurationTest.cs (.../GrassCoverErosionInwardsCalculationConfigurationTest.cs) (revision 237b9031d74382e26141395ff845d5e43f44981d) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/GrassCoverErosionInwardsCalculationConfigurationTest.cs (.../GrassCoverErosionInwardsCalculationConfigurationTest.cs) (revision 8336ede0837d35257e8b85c3b0090b0774342d90) @@ -73,8 +73,8 @@ const string dikeProfileId = "id of the dike profile"; const double orientation = 1.1; const double dikeHeight = 2.2; - const ReadHydraulicLoadsCalculationType dikeHeightCalculationType = ReadHydraulicLoadsCalculationType.CalculateByAssessmentSectionNorm; - const ReadHydraulicLoadsCalculationType overtoppingRateCalculationType = ReadHydraulicLoadsCalculationType.CalculateByProfileSpecificRequiredProbability; + const ConfigurationHydraulicLoadsCalculationType dikeHeightCalculationType = ConfigurationHydraulicLoadsCalculationType.CalculateByAssessmentSectionNorm; + const ConfigurationHydraulicLoadsCalculationType overtoppingRateCalculationType = ConfigurationHydraulicLoadsCalculationType.CalculateByProfileSpecificRequiredProbability; const bool useBreakWater = true; const ConfigurationBreakWaterType breakWaterType = ConfigurationBreakWaterType.Wall; const double breakWaterHeight = 3.3; Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/Helpers/ConfigurationHydraulicLoadsCalculationTypeConverterTest.cs =================================================================== diff -u --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/Helpers/ConfigurationHydraulicLoadsCalculationTypeConverterTest.cs (revision 0) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Configurations/Helpers/ConfigurationHydraulicLoadsCalculationTypeConverterTest.cs (revision 8336ede0837d35257e8b85c3b0090b0774342d90) @@ -0,0 +1,168 @@ +// 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 NUnit.Framework; +using Ringtoets.GrassCoverErosionInwards.IO.Configurations; +using Ringtoets.GrassCoverErosionInwards.IO.Configurations.Helpers; + +namespace Ringtoets.GrassCoverErosionInwards.IO.Test.Configurations.Helpers +{ + [TestFixture] + public class ConfigurationHydraulicLoadsCalculationTypeConverterTest + { + [Test] + public void Constructor_ExpectedValues() + { + // Call + var converter = new ConfigurationHydraulicLoadsCalculationTypeConverter(); + + // Assert + Assert.IsInstanceOf(converter); + } + + [Test] + public void CanConvertTo_String_ReturnTrue() + { + // Setup + var converter = new ConfigurationHydraulicLoadsCalculationTypeConverter(); + + // Call + bool canConvertToString = converter.CanConvertTo(typeof(string)); + + // Assert + Assert.IsTrue(canConvertToString); + } + + [Test] + public void CanConvertTo_NotString_ReturnFalse() + { + // Setup + var converter = new ConfigurationHydraulicLoadsCalculationTypeConverter(); + + // Call + bool canConvert = converter.CanConvertTo(typeof(object)); + + // Assert + Assert.IsFalse(canConvert); + } + + [Test] + [TestCase(ConfigurationHydraulicLoadsCalculationType.NoCalculation, "niet")] + [TestCase(ConfigurationHydraulicLoadsCalculationType.CalculateByAssessmentSectionNorm, "norm")] + [TestCase(ConfigurationHydraulicLoadsCalculationType.CalculateByProfileSpecificRequiredProbability, "doorsnede")] + public void ConvertTo_VariousCases_ReturnExpectedValues(ConfigurationHydraulicLoadsCalculationType value, string expectedResult) + { + // Setup + var converter = new ConfigurationHydraulicLoadsCalculationTypeConverter(); + + // Call + object result = converter.ConvertTo(value, typeof(string)); + + // Assert + Assert.AreEqual(expectedResult, result); + } + + [Test] + public void ConvertTo_InvalidReadHydraulicLoadsCalculationTypeValue_ThrowNotSupportedException() + { + // Setup + var converter = new ConfigurationHydraulicLoadsCalculationTypeConverter(); + + const ConfigurationHydraulicLoadsCalculationType invalidValue = (ConfigurationHydraulicLoadsCalculationType) 9999999; + + // Call + TestDelegate call = () => converter.ConvertTo(invalidValue, typeof(string)); + + // Assert + Assert.Throws(call); + } + + [Test] + public void ConvertTo_Object_ThrowNotSupportedException() + { + // Setup + var converter = new ConfigurationHydraulicLoadsCalculationTypeConverter(); + + // Call + TestDelegate call = () => converter.ConvertTo(ConfigurationHydraulicLoadsCalculationType.NoCalculation, typeof(object)); + + // Assert + Assert.Throws(call); + } + + [Test] + public void CanConvertFrom_String_ReturnTrue() + { + // Setup + var converter = new ConfigurationHydraulicLoadsCalculationTypeConverter(); + + // Call + bool canConvertFromString = converter.CanConvertFrom(typeof(string)); + + // Assert + Assert.IsTrue(canConvertFromString); + } + + [Test] + public void CanConvertFrom_NonString_ReturnFalse() + { + // Setup + var converter = new ConfigurationHydraulicLoadsCalculationTypeConverter(); + + // Call + bool canConvert = converter.CanConvertFrom(typeof(object)); + + // Assert + Assert.IsFalse(canConvert); + } + + [Test] + [TestCase("niet", ConfigurationHydraulicLoadsCalculationType.NoCalculation)] + [TestCase("norm", ConfigurationHydraulicLoadsCalculationType.CalculateByAssessmentSectionNorm)] + [TestCase("doorsnede", ConfigurationHydraulicLoadsCalculationType.CalculateByProfileSpecificRequiredProbability)] + public void ConvertFrom_VariousCases_ReturnExpectedValue(string value, ConfigurationHydraulicLoadsCalculationType expectedResult) + { + // Setup + var converter = new ConfigurationHydraulicLoadsCalculationTypeConverter(); + + // Call + object result = converter.ConvertFrom(value); + + // Assert + Assert.AreEqual(expectedResult, result); + } + + [Test] + public void ConvertFrom_UnsupportedString_ThrowNotSupportedException() + { + // Setup + var converter = new ConfigurationHydraulicLoadsCalculationTypeConverter(); + + // Call + TestDelegate call = () => converter.ConvertFrom(""); + + // Assert + Assert.Throws(call); + } + } +} \ No newline at end of file Fisheye: Tag 8336ede0837d35257e8b85c3b0090b0774342d90 refers to a dead (removed) revision in file `Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/ReadHydraulicLoadsCalculationTypeConverterTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Ringtoets.GrassCoverErosionInwards.IO.Test.csproj =================================================================== diff -u -r237b9031d74382e26141395ff845d5e43f44981d -r8336ede0837d35257e8b85c3b0090b0774342d90 --- Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Ringtoets.GrassCoverErosionInwards.IO.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.IO.Test.csproj) (revision 237b9031d74382e26141395ff845d5e43f44981d) +++ Ringtoets/GrassCoverErosionInwards/test/Ringtoets.GrassCoverErosionInwards.IO.Test/Ringtoets.GrassCoverErosionInwards.IO.Test.csproj (.../Ringtoets.GrassCoverErosionInwards.IO.Test.csproj) (revision 8336ede0837d35257e8b85c3b0090b0774342d90) @@ -54,7 +54,7 @@ - +