Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/TestFiles/ValidateOk.xml =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/TestFiles/ValidateOk.xml (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/TestFiles/ValidateOk.xml (revision 1985) @@ -0,0 +1 @@ + \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/TestFiles/ValidateError.xml =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/TestFiles/ValidateError.xml (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/TestFiles/ValidateError.xml (revision 1985) @@ -0,0 +1 @@ + \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/ValidateWarning.xml =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/ValidateWarning.xml (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/ValidateWarning.xml (revision 1985) @@ -0,0 +1 @@ + \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/ValidateInfo.xml =================================================================== diff -u --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/ValidateInfo.xml (revision 0) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/ValidateInfo.xml (revision 1985) @@ -0,0 +1 @@ + \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs =================================================================== diff -u -r1983 -r1985 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs (.../MacroStabilityInwardsKernelWrapper.cs) (revision 1983) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapper.cs (.../MacroStabilityInwardsKernelWrapper.cs) (revision 1985) @@ -27,15 +27,18 @@ using Deltares.DamEngine.Calculators.KernelWrappers.Common; using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStabilityCommon; using Deltares.DamEngine.Calculators.KernelWrappers.Interfaces; +using Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityCommon.MacroStabilityIo; using Deltares.DamEngine.Calculators.Properties; 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.DamEngine.Data.Standard.Logging; +using Deltares.MacroStability.Standard; using Deltares.WTIStability.Calculation.Wrapper; +using LogMessage = Deltares.DamEngine.Data.Standard.Logging.LogMessage; +using LogMessageType = Deltares.DamEngine.Data.Standard.Logging.LogMessageType; namespace Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityInwards { @@ -53,8 +56,8 @@ public FailureMechanismParametersMStab FailureMechanismParametersMStab { get; set; } //ToDo MWDAM-? Use same as for DGeoStability or create new one? public bool tmpPresumePrepareSucceeds; //ToDo MWDAM-1356 - public bool tmpPresumeInputValid; //ToDo MWDAM-1367 - public bool tmpPresumeRunSucceeds; //ToDo MWDAM-1356, MWDAM-1367, MWDAM-1357 + public bool tmpPresumeInputValid; //ToDo MWDAM-1356 + public bool tmpPresumeRunSucceeds; //ToDo MWDAM-1356, MWDAM-1357 /// /// Prepares the specified dam kernel input. @@ -169,27 +172,26 @@ internal void ParseValidationResult(string xmlValidationResult, out List messages) { messages = new List(); - // ToDo MWDAM-1367: Parse the xml from the kernel and add message with type Error, Info or Warning - // start of temporary test code - if (tmpPresumeInputValid) + var validationResults = WtiDeserializer.DeserializeValidation(xmlValidationResult); + foreach (var result in validationResults) { - // only an info/warning message, presumed input valid for test - messages.Add(new LogMessage() + messages.Add(new LogMessage { - Message = "test info message", - MessageType = LogMessageType.Info + Message = result.Text, + MessageType = ConvertValidationResultTypeToLogMessageType(result.MessageType) }); } - else + } + + internal static LogMessageType ConvertValidationResultTypeToLogMessageType(ValidationResultType messageType) + { + var translationTable = new Dictionary() { - // add an error message, presumed input not valid for test - messages.Add(new LogMessage() - { - Message = "test error message", - MessageType = LogMessageType.Error - }); - } - // end of temporary test code. next code must be enough, presumed that the kernel does all the validation + {ValidationResultType.Info, LogMessageType.Info}, + {ValidationResultType.Warning, LogMessageType.Warning}, + {ValidationResultType.Error, LogMessageType.Error} + }; + return translationTable[messageType]; } /// @@ -208,7 +210,6 @@ PerformStabilityCalculation(out messages, macroStabilityOutput, macroStabilityInput); } - private void PerformStabilityCalculation(out List messages, MacroStabilityOutput macroStabilityOutput, MacroStabilityInput macroStabilityInput) { Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj =================================================================== diff -u -r1983 -r1985 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 1983) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 1985) @@ -40,6 +40,7 @@ False ..\..\lib\FailureMechanisms\Macrostability\Deltares.MacroStability.Kernel.dll + False ..\..\lib\FailureMechanisms\WbiPipingMerged\Deltares.WTIPiping.Merged.dll @@ -162,6 +163,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + PreserveNewest @@ -174,9 +181,15 @@ PreserveNewest + + PreserveNewest + PreserveNewest + + PreserveNewest + Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapperTests.cs =================================================================== diff -u -r1983 -r1985 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapperTests.cs (.../MacroStabilityInwardsKernelWrapperTests.cs) (revision 1983) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/MacroStabilityInwardsKernelWrapperTests.cs (.../MacroStabilityInwardsKernelWrapperTests.cs) (revision 1985) @@ -31,9 +31,11 @@ using Deltares.DamEngine.Data.General; using Deltares.DamEngine.Data.General.Results; using Deltares.DamEngine.Data.Standard.Calculation; -using Deltares.DamEngine.Data.Standard.Logging; using Deltares.DamEngine.TestHelpers.Factories; +using Deltares.MacroStability.Standard; using NUnit.Framework; +using LogMessage = Deltares.DamEngine.Data.Standard.Logging.LogMessage; +using LogMessageType = Deltares.DamEngine.Data.Standard.Logging.LogMessageType; namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.MacroStabilityInwards { @@ -102,7 +104,7 @@ var macroStabilityOutput2 = new MacroStabilityOutput(); macroStabilityOutput2.CalculationResult = CalculationResult.NoRun; messages.Clear(); - // ToDo MWDAM-1367: Not clear yet what input must be provided to make Validate succeed. Temporary test code added. + // ToDo MWDAM-1356: Not clear yet what input must be provided to make Validate succeed. Temporary test code added. // start of temporary test code kernelWrapper.tmpPresumeInputValid = true; //ToDo replace by input that makes Validate succeed // end of temporary test code @@ -118,33 +120,37 @@ var kernelWrapper = new MacroStabilityInwardsKernelWrapper(); var xmlFileName = Path.Combine(TestFolder, "ValidateOk.xml"); string xmlValidationResult = File.ReadAllText(xmlFileName); - // start of temporary test code - kernelWrapper.tmpPresumeInputValid = true; //ToDo remove when ParseValidationResult is implemented - // end of temporary test code kernelWrapper.ParseValidationResult(xmlValidationResult, out messages); - //Assert.AreEqual(0, messages.Count); // no message in ValidateOk ToDo enable when ParseValidationResult is implemented - Assert.AreEqual(1, messages.Count); // info message in temporary test code ToDo remove when ParseValidationResult is implemented - Assert.AreEqual(LogMessageType.Info, messages[0].MessageType); //ToDo remove when ParseValidationResult is implemented, I have no example with Info message + Assert.AreEqual(0, messages.Count); } [Test] - public void TestParseValidationResultError() + [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.")] + public void TestParseValidationResultMessages(string fileName, LogMessageType logMessageType, string message) { List messages; var kernelWrapper = new MacroStabilityInwardsKernelWrapper(); - var xmlFileName = Path.Combine(TestFolder, "ValidateError.xml"); + var xmlFileName = Path.Combine(TestFolder, fileName); string xmlValidationResult = File.ReadAllText(xmlFileName); - // start of temporary test code - kernelWrapper.tmpPresumeInputValid = false; //ToDo remove when ParseValidationResult is implemented - // end of temporary test code kernelWrapper.ParseValidationResult(xmlValidationResult, out messages); Assert.AreEqual(1, messages.Count); - Assert.AreEqual(LogMessageType.Error, messages[0].MessageType); - //Assert.AreEqual("Voor geval 'Klei dijk op klei'(1A) moet de laag onder de dijk geen watervoerende laag zijn.", - //messages[0].Message);//ToDo enable when ParseValidationResult is implemented + Assert.AreEqual(logMessageType, messages[0].MessageType); + Assert.AreEqual(message, messages[0].Message); } [Test] + [TestCase(ValidationResultType.Info, LogMessageType.Info)] + [TestCase(ValidationResultType.Warning, LogMessageType.Warning)] + [TestCase(ValidationResultType.Error, LogMessageType.Error)] + public void ConvertValidationResultTypeToLogMessageType(ValidationResultType validationResultType, LogMessageType logMessageType) + { + Assert.AreEqual(logMessageType, + MacroStabilityInwardsKernelWrapper.ConvertValidationResultTypeToLogMessageType(validationResultType)); + } + + [Test] public void TestParseRunResult() { const double diff = 0.001; @@ -261,7 +267,7 @@ List messages; kernelWrapper.tmpPresumeInputValid = true; //ToDo replace by input that makes Validate succeed var errorCount = kernelWrapper.Validate(kernelDataInput, kernelDataOutput, out messages); - // ToDo MWDAM-1367: Not clear yet what input must be provided to make Validate succeed. Skip for now. + // 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 Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/ValidateError.xml =================================================================== diff -u -r1983 -r1985 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/ValidateError.xml (.../ValidateError.xml) (revision 1983) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/ValidateError.xml (.../ValidateError.xml) (revision 1985) @@ -1,6 +1 @@ - - - - - - \ No newline at end of file + \ No newline at end of file Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/MacroStabilityIoTests.cs =================================================================== diff -u -r1973 -r1985 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/MacroStabilityIoTests.cs (.../MacroStabilityIoTests.cs) (revision 1973) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityCommon/MacroStabilityIoTests.cs (.../MacroStabilityIoTests.cs) (revision 1985) @@ -23,7 +23,7 @@ using NUnit.Framework; using Deltares.MacroStability.Kernel; using Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityCommon.MacroStabilityIo; -using Deltares.DamEngine.TestHelpers; +using Deltares.MacroStability.Standard; namespace Deltares.DamEngine.Calculators.Tests.KernelWrappers.MacroStabilityCommon { @@ -49,5 +49,24 @@ // Then the strings are equal Assert.AreEqual(xmlInput, xmlOutput); } + + [TestCase("ValidateOk.xml")] + [TestCase("ValidateError.xml")] + public void GivenValidationResultFileWhenDeserializingAndSerializingThenTheStringsAreEqual(string fileNameIn) + { + // Given validation result file from kernel + string fullFileNameIn = Path.Combine(WtiFilesMap, fileNameIn); + + // When Deserializing and Serializing + string xmlInput = File.ReadAllText(fullFileNameIn); + string fileNameOut = fileNameIn + ".out"; + string fullFileNameOut = Path.Combine(WtiFilesMap, fileNameOut); + var validationResults = WtiDeserializer.DeserializeValidation(xmlInput); + string xmlOutput = WtiSerializer.SerializeValidation(validationResults); + File.WriteAllText(fullFileNameOut, xmlOutput); + + // Then the strings are equal + Assert.AreEqual(xmlInput, xmlOutput); + } } } Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/WTIDeserializer.cs =================================================================== diff -u -r1972 -r1985 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/WTIDeserializer.cs (.../WTIDeserializer.cs) (revision 1972) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/MacroStabilityCommon/MacroStabilityIo/WTIDeserializer.cs (.../WTIDeserializer.cs) (revision 1985) @@ -109,7 +109,7 @@ XmlDocument document = new XmlDocument(); document.LoadXml(xml); - document.Schemas.Add(GetSchema("Deltares.WTIStability.IO.WTIStabilityModelValidation.xsd", false)); + document.Schemas.Add(GetSchema("Deltares.DamEngine.Calculators.KernelWrappers.MacroStabilityCommon.MacroStabilityIo.WTIStabilityModelValidation.xsd", false)); // xsd validation document.Validate(ValidationEventHandler); Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/ValidateOk.xml =================================================================== diff -u -r1983 -r1985 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/ValidateOk.xml (.../ValidateOk.xml) (revision 1983) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/MacroStabilityInwards/TestFiles/ValidateOk.xml (.../ValidateOk.xml) (revision 1985) @@ -1,4 +1 @@ - - - - \ No newline at end of file + \ No newline at end of file