Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/WtiMacroStabilityInwards/TestFiles/Result3False.xml
===================================================================
diff -u
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/WtiMacroStabilityInwards/TestFiles/Result3False.xml (revision 0)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/WtiMacroStabilityInwards/TestFiles/Result3False.xml (revision 1967)
@@ -0,0 +1,29 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj
===================================================================
diff -u -r1961 -r1967
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 1961)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 1967)
@@ -151,6 +151,15 @@
PreserveNewest
+
+ PreserveNewest
+
+
+ PreserveNewest
+
+
+ PreserveNewest
+
PreserveNewest
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/WtiMacroStabilityInwards/TestFiles/Result2True.xml
===================================================================
diff -u
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/WtiMacroStabilityInwards/TestFiles/Result2True.xml (revision 0)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/WtiMacroStabilityInwards/TestFiles/Result2True.xml (revision 1967)
@@ -0,0 +1,543 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
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/WtiMacroStabilityInwards/WtiMacroStabilityInwardsKernelWrapperTests.cs
===================================================================
diff -u -r1962 -r1967
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/WtiMacroStabilityInwards/WtiMacroStabilityInwardsKernelWrapperTests.cs (.../WtiMacroStabilityInwardsKernelWrapperTests.cs) (revision 1962)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/WtiMacroStabilityInwards/WtiMacroStabilityInwardsKernelWrapperTests.cs (.../WtiMacroStabilityInwardsKernelWrapperTests.cs) (revision 1967)
@@ -91,7 +91,7 @@
}
[Test]
- public void ParseValidationResultOk()
+ public void TestParseValidationResultOk()
{
List messages;
var kernelWrapper = new WtiMacroStabilityInwardsKernelWrapper();
@@ -107,7 +107,7 @@
}
[Test]
- public void ParseValidationResultError()
+ public void TestParseValidationResultError()
{
List messages;
var kernelWrapper = new WtiMacroStabilityInwardsKernelWrapper();
@@ -124,6 +124,49 @@
}
[Test]
+ public void TestParseRunResult()
+ {
+ const double diff = 0.001;
+ List messages;
+ WtiMacroStabilityOutputItem macroStabilityOutputItem = new WtiMacroStabilityOutputItem();
+ var kernelWrapper = new WtiMacroStabilityInwardsKernelWrapper();
+
+ // Result 1 succeeded, has a SafetyFactor of ca. 4.47, no messages
+ var xmlFileName = Path.Combine(TestFolder, "Result1True.xml");
+ string xmlRunResult = File.ReadAllText(xmlFileName);
+ kernelWrapper.tmpPresumeRunSucceeds = true; //ToDo remove when ParseRunResult is implemented
+ kernelWrapper.ParseRunResult(xmlRunResult, out macroStabilityOutputItem, out messages);
+ Assert.AreEqual(0, messages.Count);
+ Assert.AreEqual(CalculationResult.Succeeded, macroStabilityOutputItem.CalculationResult);
+ //Assert.AreEqual(4.47, macroStabilityOutputItem.SafetyFactor, diff); //ToDo enable when ParseRunResult is implemented
+ Assert.AreEqual(1.357, macroStabilityOutputItem.SafetyFactor, diff); //ToDo remove when ParseRunResult is implemented
+
+ // ToDo MWDAM-1357: get an example of output that has a successful run with info or warning messages
+ // Result 2 succeeded, has a SafetyFactor of ca. 1.82, no error messages
+ xmlFileName = Path.Combine(TestFolder, "Result2True.xml");
+ xmlRunResult = File.ReadAllText(xmlFileName);
+ kernelWrapper.tmpPresumeRunSucceeds = true; //ToDo remove when ParseRunResult is implemented
+ kernelWrapper.ParseRunResult(xmlRunResult, out macroStabilityOutputItem, out messages);
+ Assert.AreEqual(0, messages.Count); //ToDo remove when ParseRunResult is implemented
+ //Assert.AreEqual(1, messages.Count); //ToDo enable when ParseRunResult is implemented
+ //Assert.AreEqual(LogMessageType.Info, messages[0].MessageType); //ToDo enable when ParseRunResult is implemented
+ Assert.AreEqual(CalculationResult.Succeeded, macroStabilityOutputItem.CalculationResult);
+ //Assert.AreEqual(1.82, macroStabilityOutputItem.SafetyFactor, diff); //ToDo enable when ParseRunResult is implemented
+ Assert.AreEqual(1.357, macroStabilityOutputItem.SafetyFactor, diff); //ToDo remove when ParseRunResult is implemented
+
+ // Result 3 failed, has a SafetyFactor of NaN, has error messages
+ xmlFileName = Path.Combine(TestFolder, "Result3False.xml");
+ xmlRunResult = File.ReadAllText(xmlFileName);
+ kernelWrapper.tmpPresumeRunSucceeds = false; //ToDo remove when ParseRunResult is implemented
+ kernelWrapper.ParseRunResult(xmlRunResult, out macroStabilityOutputItem, out messages);
+ Assert.AreEqual(2, messages.Count);
+ Assert.AreEqual(LogMessageType.Error, messages[0].MessageType);
+ Assert.AreEqual(LogMessageType.Error, messages[1].MessageType);
+ Assert.AreEqual(CalculationResult.RunFailed, macroStabilityOutputItem.CalculationResult);
+ Assert.AreEqual(-1.0, macroStabilityOutputItem.SafetyFactor, diff);
+ }
+
+ [Test]
public void TestPostProcess()
{
const double diff = 0.0001;
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/WtiMacroStabilityInwards/TestFiles/Result1True.xml
===================================================================
diff -u
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/Wt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+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/WtiMacroStabilityInwards/WtiMacroStabilityInwardsKernelWrapper.cs
===================================================================
diff -u -r1965 -r1967
--- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/WtiMacroStabilityInwards/WtiMacroStabilityInwardsKernelWrapper.cs (.../WtiMacroStabilityInwardsKernelWrapper.cs) (revision 1965)
+++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/WtiMacroStabilityInwards/WtiMacroStabilityInwardsKernelWrapper.cs (.../WtiMacroStabilityInwardsKernelWrapper.cs) (revision 1967)
@@ -213,7 +213,6 @@
{
ThrowWhenWtiMacroStabilityCalculatorNull(wtiMacroStabilityCalculator);
macroStabilityOutput.CalculationResult = CalculationResult.NoRun;
- messages = new List();
macroStabilityOutput.StabilityOutputItems = new List();
//this must be code when prepare is done
@@ -234,28 +233,49 @@
if (tmpPresumeRunSucceeds)
{
//presume run succeeded
- macroStabilityOutput.CalculationResult = CalculationResult.Succeeded;
- ParseRunResult("", macroStabilityOutput, messages);
+ WtiMacroStabilityOutputItem macroStabilityOutputItem;
+ ParseRunResult("", out macroStabilityOutputItem, out messages);
+ macroStabilityOutput.CalculationResult = macroStabilityOutputItem.CalculationResult;
+ macroStabilityOutput.StabilityOutputItems.Add(macroStabilityOutputItem);
}
else
{
//presume run failed
macroStabilityOutput.CalculationResult = CalculationResult.UnexpectedError;
+ messages = new List();
messages.Add(new LogMessage(LogMessageType.Error, null, "run failed"));
}
// end of temporary test code
}
- private void ParseRunResult(string xmlRunResult, WtiMacroStabilityOutput macroStabilityOutput, List messages)
+ internal void ParseRunResult(string xmlRunResult, out WtiMacroStabilityOutputItem macroStabilityOutputItem, out List messages)
{
+ messages = new List();
// ToDo MWDAM-1357: Parse the xml from the kernel, fill results and add message with type Error, Info or Warning
- var macroStabilityOutputItem = new WtiMacroStabilityOutputItem();
+ macroStabilityOutputItem = new WtiMacroStabilityOutputItem();
// start of temporary test code
- macroStabilityOutputItem.SafetyFactor = 1.357;
+ if (tmpPresumeRunSucceeds)
+ {
+ //presume run succeeded
+ macroStabilityOutputItem.StabilityModelType = MStabModelType.UpliftVan;
+ macroStabilityOutputItem.SafetyFactor = 1.357; // presume SafetyFactor in xml output is 1.357
+ macroStabilityOutputItem.CalculationResult = CalculationResult.Succeeded; // presume Succeeded in xml output is true
+ //presume there are no messages in xml output, but there might be info or warning messages
+ }
+ else
+ {
+ // ToDo MWDAM-1357: get an example of output that has a failed run with error messages
+ //presume run failed
+ macroStabilityOutputItem.StabilityModelType = MStabModelType.UpliftVan;
+ macroStabilityOutputItem.SafetyFactor = -1; // presume SafetyFactor in xml output is NaN. Set to -1?
+ macroStabilityOutputItem.CalculationResult = CalculationResult.RunFailed; // presume Succeeded in xml output is false
+ //when run failed there are probably also error messages in the xml output
+ messages.Add(new LogMessage(LogMessageType.Error, null, "Index was out of range. Must be non-negative and less than the size of the collection.\r\nParameter name: index"));
+ messages.Add(new LogMessage(LogMessageType.Error, null, "Fatale fout in Uplift-Van berekening"));
+ }
// end of temporary test code
- macroStabilityOutput.StabilityOutputItems.Add(macroStabilityOutputItem);
}
///