Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Configurations/MacroStabilityInwardsCalculationConfigurationImporter.cs
===================================================================
diff -u -r6677bd4cf1803da9d7eeb8e945f2fb3f82b32c6e -r8d42ff2fc79d3e478b29cf122c4f35ee1a013c3c
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Configurations/MacroStabilityInwardsCalculationConfigurationImporter.cs (.../MacroStabilityInwardsCalculationConfigurationImporter.cs) (revision 6677bd4cf1803da9d7eeb8e945f2fb3f82b32c6e)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Configurations/MacroStabilityInwardsCalculationConfigurationImporter.cs (.../MacroStabilityInwardsCalculationConfigurationImporter.cs) (revision 8d42ff2fc79d3e478b29cf122c4f35ee1a013c3c)
@@ -92,7 +92,8 @@
&& TrySetSurfaceLine(calculationConfiguration, calculation)
&& TrySetStochasticSoilModel(calculationConfiguration, calculation)
&& TrySetStochasticSoilProfile(calculationConfiguration, calculation)
- && TrySetScenarioParameters(calculationConfiguration.Scenario, calculation))
+ && TrySetScenarioParameters(calculationConfiguration.Scenario, calculation)
+ && TrySetTangentLineZTopBottom(calculationConfiguration, calculation))
{
SetSimpleProperties(calculationConfiguration, calculation.InputParameters);
@@ -105,6 +106,52 @@
}
///
+ /// Assigns the tangent line Z top and tangent line Z bottom parameters to the .
+ ///
+ /// The calculation read from the imported file.
+ /// The calculation to configure.
+ /// true if no tangent line z top and tangent line z bottom was given, or when
+ /// tangent line z top and tangent line z bottom are set to the ,
+ /// false otherwise.
+ private bool TrySetTangentLineZTopBottom(MacroStabilityInwardsCalculationConfiguration calculationConfiguration,
+ MacroStabilityInwardsCalculationScenario calculation)
+ {
+ bool hasTangentLineZTop = calculationConfiguration.TangentLineZTop.HasValue;
+ bool hasTangentLineZBottom = calculationConfiguration.TangentLineZBottom.HasValue;
+
+ if (!hasTangentLineZTop && !hasTangentLineZBottom)
+ {
+ return true;
+ }
+
+ RoundedDouble tangentLineZTop = hasTangentLineZTop
+ ? (RoundedDouble) calculationConfiguration.TangentLineZTop.Value
+ : RoundedDouble.NaN;
+ RoundedDouble tangentLineZBottom = hasTangentLineZBottom
+ ? (RoundedDouble) calculationConfiguration.TangentLineZBottom.Value
+ : RoundedDouble.NaN;
+
+ MacroStabilityInwardsInput input = calculation.InputParameters;
+ try
+ {
+ input.TangentLineZTop = tangentLineZTop;
+ input.TangentLineZBottom = tangentLineZBottom;
+ }
+ catch (ArgumentException e)
+ {
+ Log.LogCalculationConversionError(string.Format(Resources.MacroStabilityInwardsCalculationConfigurationImporter_TrySetTangentLineZTopBottom_Combination_of_TangentLineZTop_0_and_TangentLineZBottom_1_invalid_Reason_2,
+ tangentLineZTop.ToPrecision(input.TangentLineZTop.NumberOfDecimalPlaces),
+ tangentLineZBottom.ToPrecision(input.TangentLineZTop.NumberOfDecimalPlaces),
+ e.Message),
+ calculation.Name);
+
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
/// Assigns the hydraulic boundary location or the assessment level that is set manually.
///
/// The calculation read from the imported file.
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Properties/Resources.Designer.cs
===================================================================
diff -u -r1fb8f412abb01d504e4f546dfed0ca365c1984ae -r8d42ff2fc79d3e478b29cf122c4f35ee1a013c3c
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 1fb8f412abb01d504e4f546dfed0ca365c1984ae)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Properties/Resources.Designer.cs (.../Resources.Designer.cs) (revision 8d42ff2fc79d3e478b29cf122c4f35ee1a013c3c)
@@ -240,6 +240,16 @@
}
///
+ /// Looks up a localized string similar to Een waarde van '{0}' als tangentlijn Z-boven en '{1}' als tangentlijn Z-onder is ongeldig. {2}.
+ ///
+ public static string MacroStabilityInwardsCalculationConfigurationImporter_TrySetTangentLineZTopBottom_Combination_of_TangentLineZTop_0_and_TangentLineZBottom_1_invalid_Reason_2 {
+ get {
+ return ResourceManager.GetString("MacroStabilityInwardsCalculationConfigurationImporter_TrySetTangentLineZTopBottom" +
+ "_Combination_of_TangentLineZTop_0_and_TangentLineZBottom_1_invalid_Reason_2", resourceCulture);
+ }
+ }
+
+ ///
/// Looks up a localized string similar to De laag bevat een ongeldige geometrie..
///
public static string MacroStabilityInwardsSoilLayerTransformer_TransformSegmentToRing_Invalid_geometry_for_Ring {
Index: Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Properties/Resources.resx
===================================================================
diff -u -r1fb8f412abb01d504e4f546dfed0ca365c1984ae -r8d42ff2fc79d3e478b29cf122c4f35ee1a013c3c
--- Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Properties/Resources.resx (.../Resources.resx) (revision 1fb8f412abb01d504e4f546dfed0ca365c1984ae)
+++ Ringtoets/MacroStabilityInwards/src/Ringtoets.MacroStabilityInwards.IO/Properties/Resources.resx (.../Resources.resx) (revision 8d42ff2fc79d3e478b29cf122c4f35ee1a013c3c)
@@ -265,4 +265,7 @@
..\Resources\MacroStabiliteitBinnenwaartsZonesSchema.xsd;System.String, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089;Windows-1252
+
+ Een waarde van '{0}' als tangentlijn Z-boven en '{1}' als tangentlijn Z-onder is ongeldig. {2}
+
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Configurations/MacroStabilityInwardsCalculationConfigurationImporterTest.cs
===================================================================
diff -u -r6677bd4cf1803da9d7eeb8e945f2fb3f82b32c6e -r8d42ff2fc79d3e478b29cf122c4f35ee1a013c3c
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Configurations/MacroStabilityInwardsCalculationConfigurationImporterTest.cs (.../MacroStabilityInwardsCalculationConfigurationImporterTest.cs) (revision 6677bd4cf1803da9d7eeb8e945f2fb3f82b32c6e)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/Configurations/MacroStabilityInwardsCalculationConfigurationImporterTest.cs (.../MacroStabilityInwardsCalculationConfigurationImporterTest.cs) (revision 8d42ff2fc79d3e478b29cf122c4f35ee1a013c3c)
@@ -20,6 +20,7 @@
// All rights reserved.
using System;
+using System.Collections.Generic;
using System.IO;
using System.Linq;
using Core.Common.Base.Data;
@@ -366,6 +367,107 @@
}
[Test]
+ [TestCase("validConfigurationCalculationContainingValidTangentLineZTopAndZBottom.xml")]
+ public void Import_ValidTangentLineZTopAndZBottom_DataAddedToModel(string file)
+ {
+ // Setup
+ string filePath = Path.Combine(importerPath, file);
+
+ var calculationGroup = new CalculationGroup();
+
+ var importer = new MacroStabilityInwardsCalculationConfigurationImporter(filePath,
+ calculationGroup,
+ Enumerable.Empty(),
+ new MacroStabilityInwardsFailureMechanism());
+
+ // Call
+ bool successful = importer.Import();
+
+ // Assert
+ Assert.IsTrue(successful);
+
+ var expectedCalculations = new[]
+ {
+ new MacroStabilityInwardsCalculationScenario
+ {
+ Name = "Valid tangent line Z top and Z bottom",
+ InputParameters =
+ {
+ TangentLineZTop = (RoundedDouble) 0,
+ TangentLineZBottom = (RoundedDouble) 0
+ }
+ },
+ new MacroStabilityInwardsCalculationScenario
+ {
+ Name = "Valid tangent line Z top, tangent Z bottom NaN",
+ InputParameters =
+ {
+ TangentLineZTop = (RoundedDouble) 1,
+ TangentLineZBottom = RoundedDouble.NaN
+ }
+ },
+ new MacroStabilityInwardsCalculationScenario
+ {
+ Name = "Valid tangent line Z top",
+ InputParameters =
+ {
+ TangentLineZTop = (RoundedDouble) 1
+ }
+ },
+ new MacroStabilityInwardsCalculationScenario
+ {
+ Name = "Tangent line Z top NaN, valid tangent Z bottom",
+ InputParameters =
+ {
+ TangentLineZTop = RoundedDouble.NaN,
+ TangentLineZBottom = (RoundedDouble) 1
+ }
+ },
+ new MacroStabilityInwardsCalculationScenario
+ {
+ Name = "Valid tangent line Z bottom",
+ InputParameters =
+ {
+ TangentLineZBottom = (RoundedDouble) 1
+ }
+ }
+ };
+
+ ICalculation[] actualCalculations = calculationGroup.GetCalculations().ToArray();
+ Assert.AreEqual(expectedCalculations.Length, actualCalculations.Length);
+ for (var i = 0; i < expectedCalculations.Length; i++)
+ {
+ AssertMacroStabilityInwardsCalculationScenario(expectedCalculations[i],
+ (MacroStabilityInwardsCalculationScenario) actualCalculations[i]);
+ }
+ }
+
+ [Test]
+ public void Import_InvalidTangentLineZTopAndZBottom_LogMessageAndContinueImport()
+ {
+ // Setup
+ string filePath = Path.Combine(importerPath, "validConfigurationCalculationContainingInvalidTangentLineZTopAndZBottom.xml");
+
+ var calculationGroup = new CalculationGroup();
+ var importer = new MacroStabilityInwardsCalculationConfigurationImporter(filePath,
+ calculationGroup,
+ new HydraulicBoundaryLocation[0],
+ new MacroStabilityInwardsFailureMechanism());
+
+ // Call
+ var successful = false;
+ Action call = () => successful = importer.Import();
+
+ // Assert
+ const string expectedMessage = "Een waarde van '0.00' als tangentlijn Z-boven en '10.00' als tangentlijn Z-onder is ongeldig. " +
+ "Tangentlijn Z-onder moet kleiner zijn dan of gelijk zijn aan tangentlijn Z-boven, of NaN. " +
+ "Berekening 'Calculation' is overgeslagen.";
+ TestHelper.AssertLogMessageIsGenerated(call, expectedMessage, 1);
+ Assert.IsTrue(successful);
+ CollectionAssert.IsEmpty(calculationGroup.Children);
+ }
+
+ [Test]
[TestCase(false, "validConfigurationFullCalculationContainingHydraulicBoundaryLocation.xml")]
[TestCase(true, "validConfigurationFullCalculationContainingAssessmentLevel.xml")]
public void Import_ValidConfigurationWithValidHydraulicBoundaryData_DataAddedToModel(bool manualAssessmentLevel, string file)
@@ -443,6 +545,8 @@
CreateZones = true,
MoveGrid = true,
DikeSoilScenario = MacroStabilityInwardsDikeSoilScenario.SandDikeOnClay,
+ TangentLineZTop = (RoundedDouble) 10,
+ TangentLineZBottom = (RoundedDouble) 1,
GridDeterminationType = MacroStabilityInwardsGridDeterminationType.Automatic,
TangentLineDeterminationType = MacroStabilityInwardsTangentLineDeterminationType.LayerSeparated
},
@@ -494,11 +598,30 @@
Assert.AreEqual(expectedInput.MoveGrid, actualInput.MoveGrid);
Assert.AreEqual(expectedInput.DikeSoilScenario, actualInput.DikeSoilScenario);
+ Assert.AreEqual(expectedInput.TangentLineZTop, actualInput.TangentLineZTop);
+ Assert.AreEqual(expectedInput.TangentLineZBottom, actualInput.TangentLineZBottom);
+
Assert.AreEqual(expectedInput.GridDeterminationType, actualInput.GridDeterminationType);
Assert.AreEqual(expectedInput.TangentLineDeterminationType, actualInput.TangentLineDeterminationType);
Assert.AreEqual(expectedCalculation.IsRelevant, actualCalculation.IsRelevant);
Assert.AreEqual(expectedCalculation.Contribution, actualCalculation.Contribution, actualCalculation.Contribution.GetAccuracy());
}
+
+ private static IEnumerable GetValidLargerThanCombinations()
+ {
+ yield return new TestCaseData(1.0, null);
+ yield return new TestCaseData(1.0, double.NaN);
+ yield return new TestCaseData(null, 0.0);
+ yield return new TestCaseData(double.NaN, 0.0);
+ yield return new TestCaseData(0.0, 0.0);
+ yield return new TestCaseData(1.0, 0.0);
+ }
+
+ private static IEnumerable GetInvalidLargerThanCombinations()
+ {
+ yield return new TestCaseData(1.0, 0.0);
+ yield return new TestCaseData(0.0, -1.0);
+ }
}
}
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/test-data/MacroStabilityInwardsCalculationConfigurationImporter/validConfigurationCalculationContainingInvalidTangentLineZTopAndZBottom.xml
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/test-data/MacroStabilityInwardsCalculationConfigurationImporter/validConfigurationCalculationContainingInvalidTangentLineZTopAndZBottom.xml (revision 0)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/test-data/MacroStabilityInwardsCalculationConfigurationImporter/validConfigurationCalculationContainingInvalidTangentLineZTopAndZBottom.xml (revision 8d42ff2fc79d3e478b29cf122c4f35ee1a013c3c)
@@ -0,0 +1,11 @@
+
+
+
+
+
+ 0
+ 10
+
+
+
+
\ No newline at end of file
Index: Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/test-data/MacroStabilityInwardsCalculationConfigurationImporter/validConfigurationCalculationContainingValidTangentLineZTopAndZBottom.xml
===================================================================
diff -u
--- Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/test-data/MacroStabilityInwardsCalculationConfigurationImporter/validConfigurationCalculationContainingValidTangentLineZTopAndZBottom.xml (revision 0)
+++ Ringtoets/MacroStabilityInwards/test/Ringtoets.MacroStabilityInwards.IO.Test/test-data/MacroStabilityInwardsCalculationConfigurationImporter/validConfigurationCalculationContainingValidTangentLineZTopAndZBottom.xml (revision 8d42ff2fc79d3e478b29cf122c4f35ee1a013c3c)
@@ -0,0 +1,43 @@
+
+
+
+
\ No newline at end of file