Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj =================================================================== diff -u -r1932 -r1941 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 1932) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 1941) @@ -147,6 +147,12 @@ PreserveNewest + + PreserveNewest + + + PreserveNewest + Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamWbiMacroStabilityInwards/DamWbiMacroStabilityInwardsKernelWrapperTests.cs =================================================================== diff -u -r1927 -r1941 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamWbiMacroStabilityInwards/DamWbiMacroStabilityInwardsKernelWrapperTests.cs (.../DamWbiMacroStabilityInwardsKernelWrapperTests.cs) (revision 1927) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamWbiMacroStabilityInwards/DamWbiMacroStabilityInwardsKernelWrapperTests.cs (.../DamWbiMacroStabilityInwardsKernelWrapperTests.cs) (revision 1941) @@ -1,5 +1,6 @@ using System.Collections.Generic; using System.Data; +using System.IO; using Deltares.DamEngine.Calculators.KernelWrappers.Common; using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStabilityCommon; using Deltares.DamEngine.Calculators.KernelWrappers.DamWbiMacroStabilityInwards; @@ -18,6 +19,7 @@ [TestFixture] public class DamWbiMacroStabilityInwardsKernelWrapperTests { + private const string TestFolder = @"..\..\Deltares.DamEngine.Calculators.Tests\KernelWrappers\DamWbiMacroStabilityInwards\TestFiles"; [Test] public void TestPrepare() @@ -89,6 +91,39 @@ } [Test] + public void ParseValidationResultOk() + { + List messages; + var kernelWrapper = new DamWbiMacroStabilityInwardsKernelWrapper(); + 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 + } + + [Test] + public void ParseValidationResultError() + { + List messages; + var kernelWrapper = new DamWbiMacroStabilityInwardsKernelWrapper(); + var xmlFileName = Path.Combine(TestFolder, "ValidateError.xml"); + 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 + } + + [Test] public void TestPostProcess() { const double diff = 0.0001; Index: DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamWbiMacroStabilityInwards/DamWbiMacroStabilityInwardsKernelWrapper.cs =================================================================== diff -u -r1927 -r1941 --- DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamWbiMacroStabilityInwards/DamWbiMacroStabilityInwardsKernelWrapper.cs (.../DamWbiMacroStabilityInwardsKernelWrapper.cs) (revision 1927) +++ DamEngine/trunk/src/Deltares.DamEngine.Calculators/KernelWrappers/DamWbiMacroStabilityInwards/DamWbiMacroStabilityInwardsKernelWrapper.cs (.../DamWbiMacroStabilityInwardsKernelWrapper.cs) (revision 1941) @@ -125,12 +125,21 @@ public int Validate(IKernelDataInput kernelDataInput, IKernelDataOutput kernelDataOutput, out List messages) { ThrowWhenWbiMacroStabilityCalculatorNull(wbiMacroStabilityCalculator); - messages = new List(); string kernelMessage = wbiMacroStabilityCalculator.Validate(); - ParseValidationResult(kernelMessage, messages); - + ParseValidationResult(kernelMessage, out messages); DamWbiMacroStabilityOutput macroStabilityOutput = (DamWbiMacroStabilityOutput)kernelDataOutput; - // ToDo MWDAM-1367: Not clear yet what input must be provided to make Validate succeed. Temporary test code added. + var numberOfErrors = messages.Count(mt => mt.MessageType == LogMessageType.Error); + if (numberOfErrors > 0) + { + macroStabilityOutput.CalculationResult = CalculationResult.InvalidInputData; + } + return numberOfErrors; + } + + 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) { @@ -149,24 +158,10 @@ Message = "test error message", MessageType = LogMessageType.Error }); - macroStabilityOutput.CalculationResult = CalculationResult.InvalidInputData; } // end of temporary test code. next code must be enough, presumed that the kernel does all the validation - - var numberOfErrors = messages.Count(mt => mt.MessageType == LogMessageType.Error); - if (numberOfErrors > 0) - { - macroStabilityOutput.CalculationResult = CalculationResult.InvalidInputData; - } - return numberOfErrors; } - private void ParseValidationResult(string xmlValidationResult, List messages) - { - - // ToDo MWDAM-1367: Parse the xml from the kernel and add message with type Error, Info or Warning - } - /// /// Executes the kernel. ///