Index: DamEngine/trunk/doc/Dam Engine - Technical Design/DAM Engine - Technical Design.tex =================================================================== diff -u -r1995 -r2001 --- DamEngine/trunk/doc/Dam Engine - Technical Design/DAM Engine - Technical Design.tex (.../DAM Engine - Technical Design.tex) (revision 1995) +++ DamEngine/trunk/doc/Dam Engine - Technical Design/DAM Engine - Technical Design.tex (.../DAM Engine - Technical Design.tex) (revision 2001) @@ -975,15 +975,19 @@ \small \begin{tabular}{|p{60mm}|p{\textwidth-60mm-24pt}|} \hline \textbf{WBI Macrostability} WTIStabilityModelResult.xsd->WTIStabilityModelResult & \textbf{\ProgramName} DamDesignResult.xsd->StabilityDesignResults \\ \hline + Calculated & CalculationResult\\ \hline SafetyFactor & SafetyFactor\\ \hline Messages & ResultMessage\\ \hline - MinimumSafetyCurve -> first Slice, TopLeftPoint X & Zone1EntryPointX\\ \hline - MinimumSafetyCurve -> last Slice, TopRightPoint X & Zone1ExitPointX\\ \hline + MinimumSafetyCurve -> first Slice, TopLeftPoint X & CircleSurfacePointLeftXCoordinate\\ \hline + MinimumSafetyCurve -> last Slice, TopRightPoint X & CircleSurfacePointRightXCoordinate\\ \hline ModelOption & StabilityModelType\\ \hline \end{tabular} \caption{\small Mapping of the \WbiKernel validation result to the \ProgramName.} \label{table-MappingCalculationResultWbiMacrostability} \end{table} +Calculated is a boolean. When Calculated is true the CalculationResult is Succeeded, otherwise RunFailed. +The type of message can be Info, Warning or Error. +Presumed is that when Calculated is true, there are no error messages. %------------------------------------------------------------------------------ Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/Result2True.xml =================================================================== diff -u -r1983 -r2001 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/Result2True.xml (.../Result2True.xml) (revision 1983) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/Result2True.xml (.../Result2True.xml) (revision 2001) @@ -1,543 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs =================================================================== diff -u -r1985 -r2001 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs (.../MacroStabilityInwardsKernelWrapper.cs) (revision 1985) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs (.../MacroStabilityInwardsKernelWrapper.cs) (revision 2001) @@ -32,11 +32,12 @@ using Deltares.DamEngine.Data.Design; using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.General.Results; -using Deltares.DamEngine.Data.Geometry; using Deltares.DamEngine.Data.Geotechnics; using Deltares.DamEngine.Data.Standard.Calculation; +using Deltares.MacroStability.Geometry; using Deltares.MacroStability.Standard; using Deltares.WTIStability.Calculation.Wrapper; +using GeometryPoint = Deltares.DamEngine.Data.Geometry.GeometryPoint; using LogMessage = Deltares.DamEngine.Data.Standard.Logging.LogMessage; using LogMessageType = Deltares.DamEngine.Data.Standard.Logging.LogMessageType; @@ -57,7 +58,7 @@ public bool tmpPresumePrepareSucceeds; //ToDo MWDAM-1356 public bool tmpPresumeInputValid; //ToDo MWDAM-1356 - public bool tmpPresumeRunSucceeds; //ToDo MWDAM-1356, MWDAM-1357 + public bool tmpPresumeRunSucceeds; //ToDo MWDAM-1356 /// /// Prepares the specified dam kernel input. @@ -178,12 +179,12 @@ messages.Add(new LogMessage { Message = result.Text, - MessageType = ConvertValidationResultTypeToLogMessageType(result.MessageType) + MessageType = ConvertKernelValidationResultTypeToLogMessageType(result.MessageType) }); } } - internal static LogMessageType ConvertValidationResultTypeToLogMessageType(ValidationResultType messageType) + internal static LogMessageType ConvertKernelValidationResultTypeToLogMessageType(ValidationResultType messageType) { var translationTable = new Dictionary() { @@ -216,35 +217,36 @@ ThrowWhenMacroStabilityCalculatorNull(stabilityCalculator); macroStabilityOutput.CalculationResult = CalculationResult.NoRun; macroStabilityOutput.StabilityOutputItems = new List(); + messages = new List(); //this must be code when prepare is done -// try -// { -// string kernelMessage = macroStabilityCalculator.Run(); -// ParseRunResult(kernelMessage, macroStabilityOutput, messages); -// macroStabilityOutput.CalculationResult = CalculationResult.Succeeded; -// } -// catch (Exception e) -// { -// macroStabilityOutput.CalculationResult = CalculationResult.UnexpectedError; -// messages.Add(new LogMessage(LogMessageType.Error, null, e.Message)); -// } + // try + // { + // string kernelMessage = macroStabilityCalculator.Run(); + // ParseRunResult(kernelMessage, macroStabilityOutput, messages); + // macroStabilityOutput.CalculationResult = CalculationResult.Succeeded; + // } + // catch (Exception e) + // { + // macroStabilityOutput.CalculationResult = CalculationResult.UnexpectedError; + // messages.Add(new LogMessage(LogMessageType.Error, null, e.Message)); + // } // ToDo MWDAM-1356: setting input is not done yet. Temporary test code added. // start of temporary test code if (tmpPresumeRunSucceeds) { //presume run succeeded - MacroStabilityOutputItem macroStabilityOutputItem; - ParseRunResult("", out macroStabilityOutputItem, out messages); + MacroStabilityOutputItem macroStabilityOutputItem = new MacroStabilityOutputItem(); + macroStabilityOutputItem.CalculationResult = CalculationResult.Succeeded; + macroStabilityOutputItem.SafetyFactor = 1.357; macroStabilityOutput.CalculationResult = macroStabilityOutputItem.CalculationResult; macroStabilityOutput.StabilityOutputItems.Add(macroStabilityOutputItem); } else { //presume run failed - macroStabilityOutput.CalculationResult = CalculationResult.UnexpectedError; - messages = new List(); + macroStabilityOutput.CalculationResult = CalculationResult.RunFailed; messages.Add(new LogMessage(LogMessageType.Error, null, "run failed")); } // end of temporary test code @@ -255,31 +257,61 @@ internal void ParseRunResult(string xmlRunResult, out MacroStabilityOutputItem 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 macroStabilityOutputItem = new MacroStabilityOutputItem(); - // start of temporary test code - if (tmpPresumeRunSucceeds) + var calculationResults = WtiDeserializer.DeserializeResult(xmlRunResult); + var slicesCount = calculationResults.Curve.Slices.Count; + if (slicesCount > 0) { - //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 + calculationResults.XMinEntry = calculationResults.Curve.Slices[0].TopLeftX; + calculationResults.XMaxEntry = calculationResults.Curve.Slices[slicesCount - 1].TopRightX; } 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")); + macroStabilityOutputItem.CalculationResult = CalculationResult.UnexpectedError; } - // end of temporary test code + + macroStabilityOutputItem.CalculationResult = calculationResults.Calculated ? + CalculationResult.Succeeded : CalculationResult.RunFailed; + macroStabilityOutputItem.SafetyFactor = calculationResults.FactorOfSafety; + macroStabilityOutputItem.CircleSurfacePointLeftXCoordinate = calculationResults.XMinEntry; + macroStabilityOutputItem.CircleSurfacePointRightXCoordinate = calculationResults.XMaxEntry; + macroStabilityOutputItem.StabilityModelType = ConvertKernelModelOptionsTypeToMStabModelType(calculationResults.ModelOption); + foreach (var message in calculationResults.Messages) + { + messages.Add(new LogMessage + { + Message = message.Message, + MessageType = ConvertKernelLogMessageTypeToLogMessageType(message.MessageType) + }); + } } + internal static MStabModelType ConvertKernelModelOptionsTypeToMStabModelType(ModelOptions modelOption) + { + var translationTable = new Dictionary() + { + {ModelOptions.Bishop, MStabModelType.Bishop}, + {ModelOptions.UpliftVan, MStabModelType.UpliftVan}, + {ModelOptions.UpliftSpencer, MStabModelType.UpliftSpencer}, + {ModelOptions.Spencer, MStabModelType.Spencer}, + {ModelOptions.Fellenius, MStabModelType.Fellenius}, + {ModelOptions.BishopProbabilityRandomField, MStabModelType.BishopRandomField}, + {ModelOptions.HorizontalBalance, MStabModelType.HorizontalBalance}, + }; + return translationTable[modelOption]; + } + + internal static LogMessageType ConvertKernelLogMessageTypeToLogMessageType(MacroStability.Standard.LogMessageType messageType) + { + var translationTable = new Dictionary() + { + {MacroStability.Standard.LogMessageType.Info, LogMessageType.Info}, + {MacroStability.Standard.LogMessageType.Warning, LogMessageType.Warning}, + {MacroStability.Standard.LogMessageType.Error, LogMessageType.Error} + }; + return translationTable[messageType]; + } + /// /// Creates the calculator for stability based on kernel input. /// @@ -438,9 +470,7 @@ double fosRequired = damKernelInput.Location.ModelFactors.RequiredSafetyFactorStabilityInnerSlope.Value; double fosAchieved = macroStabilityOutput.StabilityOutputItems[0].SafetyFactor; - //ToDo MWDAM-1357: not clear where the exitPointXCoordinate must come from - //double exitPointXCoordinate = macroStabilityOutput.StabilityOutputItems[0].CircleSurfacePointRightXCoordinate; - double exitPointXCoordinate = 1.123; // ToDo replace by value above. set a value for test. + double exitPointXCoordinate = macroStabilityOutput.StabilityOutputItems[0].CircleSurfacePointRightXCoordinate; GeometryPoint limitPointForShoulderDesign = damKernelInput.Location.SurfaceLine.GetLimitPointForShoulderDesign(); evaluationMessage = String.Format(Resources.FactorAchievedVsFactorRequired, fosAchieved, fosRequired); if (exitPointXCoordinate > limitPointForShoulderDesign.X) Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/Result1True.xml =================================================================== diff -u -r1983 -r2001 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/Result1True.xml (.../Result1True.xml) (revision 1983) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/Result1True.xml (.../Result1True.xml) (revision 2001) @@ -1,464 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/Result3False.xml =================================================================== diff -u -r1983 -r2001 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/Result3False.xml (.../Result3False.xml) (revision 1983) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/Result3False.xml (.../Result3False.xml) (revision 2001) @@ -1,29 +1 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file + \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityOutputItem.cs =================================================================== diff -u -r1983 -r2001 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityOutputItem.cs (.../MacroStabilityOutputItem.cs) (revision 1983) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityOutputItem.cs (.../MacroStabilityOutputItem.cs) (revision 2001) @@ -35,6 +35,22 @@ public CalculationResult CalculationResult { get; set; } /// + /// Gets or sets the circle surface point left x coordinate + /// + /// + /// The circle surface point left x coordinate + /// + public double CircleSurfacePointLeftXCoordinate; + + /// + /// Gets or sets the circle surface point right x coordinate + /// + /// + /// The circle surface point right x coordinate + /// + public double CircleSurfacePointRightXCoordinate; + + /// /// Gets or sets the safety factor. /// /// Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapperTests.cs =================================================================== diff -u -r1988 -r2001 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapperTests.cs (.../MacroStabilityInwardsKernelWrapperTests.cs) (revision 1988) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapperTests.cs (.../MacroStabilityInwardsKernelWrapperTests.cs) (revision 2001) @@ -33,6 +33,7 @@ using Deltares.DamEngine.Data.General.Results; using Deltares.DamEngine.Data.Standard.Calculation; using Deltares.DamEngine.TestHelpers.Factories; +using Deltares.MacroStability.Geometry; using Deltares.MacroStability.Standard; using NUnit.Framework; using LogMessage = Deltares.DamEngine.Data.Standard.Logging.LogMessage; @@ -125,7 +126,6 @@ Assert.AreEqual(0, messages.Count); } - [Test] [TestCase("ValidateInfo.xml", LogMessageType.Info, "Dit is een Info bericht voor test")] [TestCase("ValidateWarning.xml", LogMessageType.Warning, "Dit is een Waarschuwings bericht voor test")] [TestCase("ValidateError.xml", LogMessageType.Error, "Voor geval 'Klei dijk op klei' (1A) moet de laag onder de dijk geen watervoerende laag zijn.")] @@ -152,60 +152,87 @@ kernelWrapper.ParseValidationResult(xmlValidationResult, out messages); } - [Test] [TestCase(ValidationResultType.Info, LogMessageType.Info)] [TestCase(ValidationResultType.Warning, LogMessageType.Warning)] [TestCase(ValidationResultType.Error, LogMessageType.Error)] - public void ConvertValidationResultTypeToLogMessageType(ValidationResultType validationResultType, LogMessageType logMessageType) + public void TestConvertKernelValidationResultTypeToLogMessageType(ValidationResultType validationResultType, LogMessageType logMessageType) { Assert.AreEqual(logMessageType, - MacroStabilityInwardsKernelWrapper.ConvertValidationResultTypeToLogMessageType(validationResultType)); + MacroStabilityInwardsKernelWrapper.ConvertKernelValidationResultTypeToLogMessageType(validationResultType)); } [Test] + // Result1True.xml is generated with BmMacrostabiliteit 'Benchmark 1-01b.wti' + // Result2True.xml is generated with BmMacrostabiliteit 'Benchmark 4-01b.wti' + // An info and warning message were manually added + // Result3False.xml is same as Result1True.xml but changed manually to Succeeded="false" SafetyFactor="NaN" + // and added an error message public void TestParseRunResult() { const double diff = 0.001; List messages; MacroStabilityOutputItem macroStabilityOutputItem = new MacroStabilityOutputItem(); var kernelWrapper = new MacroStabilityInwardsKernelWrapper(); - // Result 1 succeeded, has a SafetyFactor of ca. 4.47, no messages + // Result 1 succeeded, has a SafetyFactor of ca. 3.856, 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 + Assert.AreEqual(3.856, macroStabilityOutputItem.SafetyFactor, diff); + Assert.AreEqual(56.599, macroStabilityOutputItem.CircleSurfacePointLeftXCoordinate, diff); + Assert.AreEqual(77.665, macroStabilityOutputItem.CircleSurfacePointRightXCoordinate, diff); + Assert.AreEqual(MStabModelType.UpliftVan, macroStabilityOutputItem.StabilityModelType); - // 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 + // Result 2 succeeded, has a SafetyFactor of ca. 1.857, has info and warning, but 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(2, messages.Count); + Assert.AreEqual(LogMessageType.Info, messages[0].MessageType); + Assert.AreEqual(LogMessageType.Warning, messages[1].MessageType); 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 + Assert.AreEqual(1.857, macroStabilityOutputItem.SafetyFactor, diff); + Assert.AreEqual(48.195, macroStabilityOutputItem.CircleSurfacePointLeftXCoordinate, diff); + Assert.AreEqual(54.715, macroStabilityOutputItem.CircleSurfacePointRightXCoordinate, diff); + Assert.AreEqual(MStabModelType.UpliftVan, macroStabilityOutputItem.StabilityModelType); - // Result 3 failed, has a SafetyFactor of NaN, has error messages + // Result 3 failed - has a SafetyFactor of NaN, has an error mesage 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(1, 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); + Assert.AreEqual(double.NaN, macroStabilityOutputItem.SafetyFactor, diff); } [Test] + [TestCase(ModelOptions.Bishop, MStabModelType.Bishop)] + [TestCase(ModelOptions.UpliftVan, MStabModelType.UpliftVan)] + [TestCase(ModelOptions.UpliftSpencer, MStabModelType.UpliftSpencer)] + [TestCase(ModelOptions.Spencer, MStabModelType.Spencer)] + [TestCase(ModelOptions.Fellenius, MStabModelType.Fellenius)] + [TestCase(ModelOptions.BishopProbabilityRandomField, MStabModelType.BishopRandomField)] + [TestCase(ModelOptions.HorizontalBalance, MStabModelType.HorizontalBalance)] + public void TestConvertKernelModelOptionsTypeToMStabModelType(ModelOptions modelOptionsType, MStabModelType mStabModelType) + { + Assert.AreEqual(mStabModelType, + MacroStabilityInwardsKernelWrapper.ConvertKernelModelOptionsTypeToMStabModelType(modelOptionsType)); + } + + [TestCase(MacroStability.Standard.LogMessageType.Info, LogMessageType.Info)] + [TestCase(MacroStability.Standard.LogMessageType.Warning, LogMessageType.Warning)] + [TestCase(MacroStability.Standard.LogMessageType.Error, LogMessageType.Error)] + public void TestConvertKernelLogMessageTypeToLogMessageType(MacroStability.Standard.LogMessageType kernelLogMessageType, + LogMessageType logMessageType) + { + Assert.AreEqual(logMessageType, + MacroStabilityInwardsKernelWrapper.ConvertKernelLogMessageTypeToLogMessageType(kernelLogMessageType)); + } + + [Test] public void TestPostProcess() { const double diff = 0.0001; @@ -248,13 +275,11 @@ // Run the dll List messages; MacroStabilityInput macroStabilityInput = (MacroStabilityInput)kernelDataInput; - kernelWrapper.tmpPresumeRunSucceeds = false; //ToDo replace by input that makes Execute fail + kernelWrapper.tmpPresumeRunSucceeds = false; //ToDo MWDAM-1356 replace by input that makes Execute fail kernelWrapper.Execute(kernelDataInput, kernelDataOutput, out messages); - // ToDo MWDAM-1357: Parse the xml output from the kernel must be done MacroStabilityOutput macroStabilityOutput = (MacroStabilityOutput)kernelDataOutput; Assert.IsTrue(messages.Count > 0); - // ToDo MWDAM-1357: the kernel has no input data, therefore it will fail. Test is better when it has input data but fails for another reason - Assert.AreEqual(CalculationResult.UnexpectedError, macroStabilityOutput.CalculationResult); + Assert.AreEqual(CalculationResult.RunFailed, macroStabilityOutput.CalculationResult); } [Test] @@ -270,25 +295,22 @@ IKernelDataInput kernelDataInput; IKernelDataOutput kernelDataOutput; var kernelInput = CreateDamKernelInputForTest(); - PrepareResult prepareResult; - prepareResult = kernelWrapper.Prepare(kernelInput, 0, out kernelDataInput, out kernelDataOutput); + PrepareResult prepareResult = kernelWrapper.Prepare(kernelInput, 0, out kernelDataInput, out kernelDataOutput); // ToDo MWDAM-1356: xml input not written yet. Skip for now. //Assert.AreEqual(PrepareResult.Successful, prepareResult1); // Validate the input List messages; - kernelWrapper.tmpPresumeInputValid = true; //ToDo replace by input that makes Validate succeed + kernelWrapper.tmpPresumeInputValid = true; //ToDo MWDAM-1356: replace by input that makes Validate succeed var errorCount = kernelWrapper.Validate(kernelDataInput, kernelDataOutput, out messages); // ToDo MWDAM-1356: Not clear yet what input must be provided to make Validate succeed. Skip for now. //Assert.IsTrue(errorCount == 0); // Run the dll - kernelWrapper.tmpPresumeRunSucceeds = true; //ToDo replace by input that makes Execute succeed + kernelWrapper.tmpPresumeRunSucceeds = true; //ToDo MWDAM-1356: replace by input that makes Execute succeed kernelWrapper.Execute(kernelDataInput, kernelDataOutput, out messages); MacroStabilityOutput macroStabilityOutput = (MacroStabilityOutput)kernelDataOutput; - // ToDo MWDAM-1356: Input must be set first in Prepare - // ToDo MWDAM-1357 Parse the xml output from the kernel must be done // start of temporary test code Assert.AreEqual(0, messages.Count); Assert.AreEqual(CalculationResult.Succeeded, macroStabilityOutput.CalculationResult);