Index: DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/MultiCoreMacroStabilityTests.cs =================================================================== diff -u -r1693 -r1700 --- DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/MultiCoreMacroStabilityTests.cs (.../MultiCoreMacroStabilityTests.cs) (revision 1693) +++ DamEngine/trunk/src/Deltares.DamEngine.Interface.Tests/MultiCoreMacroStabilityTests.cs (.../MultiCoreMacroStabilityTests.cs) (revision 1700) @@ -64,10 +64,13 @@ string outputFilename = DetermineOutputFilename(fileNameOutputPrefix, mStabModelType.ToString(), analysisType.ToString(), 1); string outputString; EngineInterface engineInterface; + // Following line to force 1-core calculation to be performed always. + // Outcomment it to prevent 1-core calculation to be performed if it as already done in a previous run, to speed up the test. + if (File.Exists(outputFilename)) File.Delete(outputFilename); if (File.Exists(outputFilename)) { // This is to speed up local testing; after the first run the file will be read from disk. - // If something in the calculation results changes, the file has to be manually deleted + // If something in the calculation results changes, the file has to be deleted (see line above) // It will then be generated again in the else block of this statement outputString = File.ReadAllText(outputFilename); Debug.WriteLine("Skipping single core calculation Macrostability; results are read from file"); @@ -90,24 +93,46 @@ var outputOneCore = DamXmlSerialization.LoadOutputFromXmlString(outputString); // Calculate multicore - Debug.WriteLine("Perform multicore calculation with {0} cores Macrostability", multiCoreCount); calcDir = String.Format("TestStabInwards_{0}_{1}_{2}Core", mStabModelType.ToString(), analysisType.ToString(), multiCoreCount); - inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used - inputString = XmlAdapter.ChangeValueInXml(inputString, "MaxCalculationCores", multiCoreCount.ToString()); - engineInterface = new EngineInterface(inputString); - Assert.IsNotNull(engineInterface.DamProjectData); - outputString = engineInterface.Run(); - Assert.IsNotNull(outputString); - var outputMultiCore = DamXmlSerialization.LoadOutputFromXmlString(outputString); outputFilename = DetermineOutputFilename(fileNameOutputPrefix, mStabModelType.ToString(), analysisType.ToString(), multiCoreCount); - File.WriteAllText(outputFilename, outputString, Encoding.Unicode); + // Following line to force multicore calculation to be performed always. + // Outcomment it to prevent multicore calculation to be performed if it as already done in a previous run, to speed up the test. + if (File.Exists(outputFilename)) File.Delete(outputFilename); + if (File.Exists(outputFilename)) + { + // This is to speed up local testing; after the first run the file will be read from disk. + // If something in the calculation results changes, the file has to be deleted (see line above) + // It will then be generated again in the else block of this statement + outputString = File.ReadAllText(outputFilename); + Debug.WriteLine("Skipping multicore calculation Macrostability; results are read from file"); + } + else + { + inputString = XmlAdapter.ChangeValueInXml(inputString, "CalculationMap", calcDir); // Current directory will be used + inputString = XmlAdapter.ChangeValueInXml(inputString, "MaxCalculationCores", multiCoreCount.ToString()); + if (Directory.Exists(calcDir)) + { + Directory.Delete(calcDir, true); // delete previous results + } + Directory.CreateDirectory(calcDir); + Debug.WriteLine("Perform multicore calculation with {0} cores Macrostability", multiCoreCount); + engineInterface = new EngineInterface(inputString); + Assert.IsNotNull(engineInterface.DamProjectData); + outputString = engineInterface.Run(); + Assert.IsNotNull(outputString); + File.WriteAllText(outputFilename, outputString, Encoding.Unicode); + } + var outputMultiCore = DamXmlSerialization.LoadOutputFromXmlString(outputString); // Compare the results var differences = new List(); StringBuilder differencesStringBuilder = new StringBuilder(); foreach (DesignResult oneCoreResult in outputOneCore.Results.CalculationResults.DesignResults) { - DesignResult multiCoreResult = outputMultiCore.Results.CalculationResults.DesignResults.Where(x => x.LocationName.Equals(oneCoreResult.LocationName) && x.ProfileName.Equals(oneCoreResult.ProfileName)).FirstOrDefault(); + DesignResult multiCoreResult = outputMultiCore.Results.CalculationResults.DesignResults.FirstOrDefault(x => + x.LocationName.Equals(oneCoreResult.LocationName) && + x.ProfileName.Equals(oneCoreResult.ProfileName) && + x.StabilityDesignResults.StabilityModelType == oneCoreResult.StabilityDesignResults.StabilityModelType); if (multiCoreResult == null) { var diffString = String.Format("No mutlicore result in location '{0}', soilprofile '{1}'", oneCoreResult.LocationName, oneCoreResult.ProfileName);