Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -rbc09678ed3cac5622e2b12b440d3de2f1b57eef1 -r38f8a176fd23ddbd26dbd562c8a3ddf22a7b56d3
--- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision bc09678ed3cac5622e2b12b440d3de2f1b57eef1)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 38f8a176fd23ddbd26dbd562c8a3ddf22a7b56d3)
@@ -1757,6 +1757,16 @@
}
///
+ /// Looks up a localized string similar to De ondergrondschematisatie van het type '{0}' is niet ondersteund. Alleen ondergrondschematisaties van het type '{1}' of '{2}' zijn ondersteund..
+ ///
+ public static string SoilProfileTransformer_Cannot_tranform_Type_0_Only_types_Type_1_and_Type_2_are_supported {
+ get {
+ return ResourceManager.GetString("SoilProfileTransformer_Cannot_tranform_Type_0_Only_types_Type_1_and_Type_2_are_su" +
+ "pported", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to Kon geen stochastische ondergrondmodellen verkrijgen uit de database..
///
public static string StochasticSoilModelDatabaseReader_Failed_to_read_database {
Index: Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx
===================================================================
diff -u -rbc09678ed3cac5622e2b12b440d3de2f1b57eef1 -r38f8a176fd23ddbd26dbd562c8a3ddf22a7b56d3
--- Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision bc09678ed3cac5622e2b12b440d3de2f1b57eef1)
+++ Ringtoets/Common/src/Ringtoets.Common.IO/Properties/Resources.resx (.../Resources.resx) (revision 38f8a176fd23ddbd26dbd562c8a3ddf22a7b56d3)
@@ -886,4 +886,7 @@
Parameter '{0}' is niet lognormaal verdeeld.
+
+ De ondergrondschematisatie van het type '{0}' is niet ondersteund. Alleen ondergrondschematisaties van het type '{1}' of '{2}' zijn ondersteund.
+
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilProfileTransformer.cs
===================================================================
diff -u -r74be63b9f6ac8bc60a6754667a3bcee0485853a0 -r38f8a176fd23ddbd26dbd562c8a3ddf22a7b56d3
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilProfileTransformer.cs (.../MacroStabilityInwardsSoilProfileTransformer.cs) (revision 74be63b9f6ac8bc60a6754667a3bcee0485853a0)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/SoilProfiles/MacroStabilityInwardsSoilProfileTransformer.cs (.../MacroStabilityInwardsSoilProfileTransformer.cs) (revision 38f8a176fd23ddbd26dbd562c8a3ddf22a7b56d3)
@@ -24,6 +24,7 @@
using Ringtoets.Common.IO.Exceptions;
using Ringtoets.Common.IO.SoilProfile;
using Ringtoets.MacroStabilityInwards.Primitives;
+using RingtoetsCommonIOResources = Ringtoets.Common.IO.Properties.Resources;
namespace Ringtoets.MacroStabilityInwards.IO.SoilProfiles
{
@@ -34,22 +35,49 @@
internal static class MacroStabilityInwardsSoilProfileTransformer
{
///
- /// Transforms the generic into a
- /// .
+ /// Transforms the generic into an .
///
/// The soil profile to use in the transformation.
- /// A based on the given data.
- /// Thrown when is
- /// null.
+ /// A new based on the given data.
+ /// Thrown when is null.
/// Thrown when transformation would not result
/// in a valid transformed instance.
- public static MacroStabilityInwardsSoilProfile1D Transform(SoilProfile1D soilProfile)
+ public static IMacroStabilityInwardsSoilProfile Transform(ISoilProfile soilProfile)
{
if (soilProfile == null)
{
throw new ArgumentNullException(nameof(soilProfile));
}
+ var soilProfile1D = soilProfile as SoilProfile1D;
+ if (soilProfile1D != null)
+ {
+ return Transform(soilProfile1D);
+ }
+
+ var soilProfile2D = soilProfile as SoilProfile2D;
+ if (soilProfile2D != null)
+ {
+ return Transform(soilProfile2D);
+ }
+
+ string message = string.Format(RingtoetsCommonIOResources.SoilProfileTransformer_Cannot_tranform_Type_0_Only_types_Type_1_and_Type_2_are_supported,
+ soilProfile.GetType().Name,
+ nameof(SoilProfile1D),
+ nameof(SoilProfile2D));
+ throw new ImportedDataTransformException(message);
+ }
+
+ ///
+ /// Transforms the generic into a
+ /// .
+ ///
+ /// The soil profile to use in the transformation.
+ /// A based on the given data.
+ /// Thrown when transformation would not result
+ /// in a valid transformed instance.
+ private static MacroStabilityInwardsSoilProfile1D Transform(SoilProfile1D soilProfile)
+ {
return new MacroStabilityInwardsSoilProfile1D(soilProfile.Name,
soilProfile.Bottom,
soilProfile.Layers
@@ -64,17 +92,10 @@
///
/// The soil profile to use in the transformation.
/// A based on the given data.
- /// Thrown when is
- /// null.
/// Thrown when transformation would not result
/// in a valid transformed instance.
- public static MacroStabilityInwardsSoilProfile2D Transform(SoilProfile2D soilProfile)
+ private static MacroStabilityInwardsSoilProfile2D Transform(SoilProfile2D soilProfile)
{
- if (soilProfile == null)
- {
- throw new ArgumentNullException(nameof(soilProfile));
- }
-
return new MacroStabilityInwardsSoilProfile2D(soilProfile.Name,
soilProfile.Layers
.Select(MacroStabilityInwardsSoilLayerTransformer.Transform),
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilProfileTransformerTest.cs
===================================================================
diff -u -r12b385b14eb734d1b09fbcf011b738cbda145205 -r38f8a176fd23ddbd26dbd562c8a3ddf22a7b56d3
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilProfileTransformerTest.cs (.../MacroStabilityInwardsSoilProfileTransformerTest.cs) (revision 12b385b14eb734d1b09fbcf011b738cbda145205)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/SoilProfiles/MacroStabilityInwardsSoilProfileTransformerTest.cs (.../MacroStabilityInwardsSoilProfileTransformerTest.cs) (revision 38f8a176fd23ddbd26dbd562c8a3ddf22a7b56d3)
@@ -22,6 +22,8 @@
using System;
using System.Linq;
using NUnit.Framework;
+using Rhino.Mocks;
+using Ringtoets.Common.IO.Exceptions;
using Ringtoets.Common.IO.SoilProfile;
using Ringtoets.Common.IO.TestUtil;
using Ringtoets.MacroStabilityInwards.IO.SoilProfiles;
@@ -33,27 +35,46 @@
public class MacroStabilityInwardsSoilProfileTransformerTest
{
[Test]
- public void SoilProfile1DTransform_SoilProfileNull_ThrowsArgumentNullException()
+ public void Transform_SoilProfileNull_ThrowsArgumentNullException()
{
// Call
- TestDelegate test = () => MacroStabilityInwardsSoilProfileTransformer.Transform((SoilProfile1D) null);
+ TestDelegate test = () => MacroStabilityInwardsSoilProfileTransformer.Transform(null);
// Assert
var exception = Assert.Throws(test);
Assert.AreEqual("soilProfile", exception.ParamName);
}
[Test]
- public void SoilProfile1DTransform_ValidProfile_ReturnMacroStabilityInwardsSoilProfile1D()
+ public void Transform_InvalidSoilProfile_ThrowsImportedDataTransformException()
{
// Setup
+ var mocks = new MockRepository();
+ var soilProfile = mocks.Stub();
+ mocks.ReplayAll();
+
+ // Call
+ TestDelegate test = () => MacroStabilityInwardsSoilProfileTransformer.Transform(soilProfile);
+
+ // Assert
+ var exception = Assert.Throws(test);
+ string message = $"De ondergrondschematisatie van het type '{soilProfile.GetType().Name}' is niet ondersteund. " +
+ "Alleen ondergrondschematisaties van het type 'SoilProfile1D' of 'SoilProfile2D' zijn ondersteund.";
+ Assert.AreEqual(message, exception.Message);
+ mocks.VerifyAll();
+ }
+
+ [Test]
+ public void Transform_ValidSoilProfile1D_ReturnMacroStabilityInwardsSoilProfile1D()
+ {
+ // Setup
var profile = new SoilProfile1D(1, "test", 3, new []
{
new SoilLayer1D(4),
});
// Call
- MacroStabilityInwardsSoilProfile1D transformedProfile = MacroStabilityInwardsSoilProfileTransformer.Transform(profile);
+ var transformedProfile = (MacroStabilityInwardsSoilProfile1D) MacroStabilityInwardsSoilProfileTransformer.Transform(profile);
// Assert
Assert.AreEqual(profile.Id, transformedProfile.MacroStabilityInwardsSoilProfileId);
@@ -64,27 +85,16 @@
}
[Test]
- public void SoilProfile2DTransform_SoilProfileNull_ThrowsArgumentNullException()
+ public void Transform_ValidSoilProfile2D_ReturnMacroStabilityInwardsSoilProfile1D()
{
- // Call
- TestDelegate test = () => MacroStabilityInwardsSoilProfileTransformer.Transform((SoilProfile2D) null);
-
- // Assert
- var exception = Assert.Throws(test);
- Assert.AreEqual("soilProfile", exception.ParamName);
- }
-
- [Test]
- public void SoilProfile2DTransform_ValidProfile_ReturnMacroStabilityInwardsSoilProfile1D()
- {
// Setup
var profile = new SoilProfile2D(1, "test", new []
{
SoilLayer2DTestFactory.CreateSoilLayer2D()
});
// Call
- MacroStabilityInwardsSoilProfile2D transformedProfile = MacroStabilityInwardsSoilProfileTransformer.Transform(profile);
+ var transformedProfile = (MacroStabilityInwardsSoilProfile2D) MacroStabilityInwardsSoilProfileTransformer.Transform(profile);
// Assert
Assert.AreEqual(profile.Id, transformedProfile.MacroStabilityInwardsSoilProfileId);
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -rbc09678ed3cac5622e2b12b440d3de2f1b57eef1 -r38f8a176fd23ddbd26dbd562c8a3ddf22a7b56d3
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision bc09678ed3cac5622e2b12b440d3de2f1b57eef1)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 38f8a176fd23ddbd26dbd562c8a3ddf22a7b56d3)
@@ -199,16 +199,6 @@
}
///
- /// Looks up a localized string similar to De ondergrondschematisatie van het type '{0}' is niet ondersteund. Alleen ondergrondschematisaties van het type '{1}' of '{2}' zijn ondersteund..
- ///
- public static string PipingSoilProfileTransformer_Cannot_tranform_Type_0_Only_types_Type_1_and_Type_2_are_supported {
- get {
- return ResourceManager.GetString("PipingSoilProfileTransformer_Cannot_tranform_Type_0_Only_types_Type_1_and_Type_2_" +
- "are_supported", resourceCulture);
- }
- }
-
- ///
/// Looks up a localized string similar to Verzadigd gewicht.
///
public static string SoilLayer_BelowPhreaticLevelDistribution_Description {
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx
===================================================================
diff -u -rbc09678ed3cac5622e2b12b440d3de2f1b57eef1 -r38f8a176fd23ddbd26dbd562c8a3ddf22a7b56d3
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision bc09678ed3cac5622e2b12b440d3de2f1b57eef1)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/Properties/Resources.resx (.../Resources.resx) (revision 38f8a176fd23ddbd26dbd562c8a3ddf22a7b56d3)
@@ -166,7 +166,4 @@
..\Resources\PipingConfiguratieSchema.xsd;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
-
- De ondergrondschematisatie van het type '{0}' is niet ondersteund. Alleen ondergrondschematisaties van het type '{1}' of '{2}' zijn ondersteund.
-
\ No newline at end of file
Index: Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilProfileTransformer.cs
===================================================================
diff -u -r09693d79085118c47709b7059ab7c1ef459ad2aa -r38f8a176fd23ddbd26dbd562c8a3ddf22a7b56d3
--- Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilProfileTransformer.cs (.../PipingSoilProfileTransformer.cs) (revision 09693d79085118c47709b7059ab7c1ef459ad2aa)
+++ Ringtoets/Piping/src/Ringtoets.Piping.IO/SoilProfiles/PipingSoilProfileTransformer.cs (.../PipingSoilProfileTransformer.cs) (revision 38f8a176fd23ddbd26dbd562c8a3ddf22a7b56d3)
@@ -26,6 +26,7 @@
using Ringtoets.Common.IO.SoilProfile;
using Ringtoets.Piping.IO.Properties;
using Ringtoets.Piping.Primitives;
+using RingtoetsCommonIOResources = Ringtoets.Common.IO.Properties.Resources;
namespace Ringtoets.Piping.IO.SoilProfiles
{
@@ -62,7 +63,7 @@
return CreatePipingSoilProfile(soilProfile2D);
}
- string message = string.Format(Resources.PipingSoilProfileTransformer_Cannot_tranform_Type_0_Only_types_Type_1_and_Type_2_are_supported,
+ string message = string.Format(RingtoetsCommonIOResources.SoilProfileTransformer_Cannot_tranform_Type_0_Only_types_Type_1_and_Type_2_are_supported,
soilProfile.GetType().Name,
nameof(SoilProfile1D),
nameof(SoilProfile2D));