Index: dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/TestData/Expected1D1.xml
===================================================================
diff -u
--- dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/TestData/Expected1D1.xml (revision 0)
+++ dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/TestData/Expected1D1.xml (revision 803)
@@ -0,0 +1,59 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
Index: dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/MStabXmlDocTests.cs
===================================================================
diff -u -r801 -r803
--- dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/MStabXmlDocTests.cs (.../MStabXmlDocTests.cs) (revision 801)
+++ dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/MStabXmlDocTests.cs (.../MStabXmlDocTests.cs) (revision 803)
@@ -19,16 +19,15 @@
// Stichting Deltares and remain full property of Stichting Deltares at all times.
// All rights reserved.
-using System;
using System.Collections.Generic;
+using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Xml.Linq;
using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStability;
using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStability.Assemblers;
using Deltares.DamEngine.Data.Design;
using Deltares.DamEngine.Data.General;
-using Deltares.DamEngine.Data.Geometry;
using Deltares.DamEngine.Data.Geotechnics;
using Deltares.DamEngine.Data.Standard.Logging;
using Deltares.DamEngine.TestHelpers;
@@ -39,51 +38,29 @@
[TestFixture]
public class MStabXmlDocTests
{
+ private const string TestFolder = @"..\..\Deltares.DamEngine.Calculators.Tests\KernelWrappers\DamMacroStability\TestData";
+
[Test]
public void TestCreateMStabXmlDoc()
{
List errorMessages;
- var stabilityProjectFilename = "testproject";
- const string soilGeometry2DName = @"KernelWrappers\DamMacroStability\TestData\1D1.sti";
- const string soilDbName = @"KernelWrappers\DamMacroStability\TestData\soilmaterials.mdb";
+ const string stabilityProjectFilename = "testproject";
+ var xmlFileName = Path.Combine(TestFolder, "testproject.xml");
+ // Expected1D1.xml was generated with Dam Classic revision 745 with test CanCalculateStabilitySafetyFactorGeometry2D
+ // In the file that is generated here sometimes value -0 is written instead of 0.
+ // To compare the two files in an easy way, Expected1D1.xml was manually modified
+ var expectedxmlFileName = Path.Combine(TestFolder, "Expected1D1.xml");
+ var soilGeometry2DName = Path.Combine(TestFolder, "1D1.sti");
+ var soilDbName = Path.Combine(TestFolder, "soilmaterials.mdb");
var requiredSafetyFactor = 1.2;
-// const string testFolder = @"..\..\Deltares.DamEngine.Calculators.Tests\KernelWrappers\DamMacroStability\TestData";
-// var xmlFileName = Path.Combine(testFolder, "test.xml");
-// var stiFileName = Path.Combine(testFolder, "test.sti");
-// var geometryFileName = Path.Combine(testFolder, "DWP_1.sti");
-// var soilDbName = Path.Combine(testFolder, "DAM Tutorial Design0.soilmaterials.mdb");
-// var expectedStiFileName = Path.Combine(testFolder, "expectedTest.sti");
-// if (File.Exists(stiFileName))
-// {
-// File.Delete(stiFileName);
-// }
-//
-// // modify name of output sti file
-// XDocument xDocument = XDocument.Load(xmlFileName);
-// XElement inputElement = (from element in xDocument.Root.Descendants()
-// where element.Name.LocalName == DamMStabAssembler.XmlElementNameInput
-// select element).Single();
-// XAttribute mstabFileName = inputElement.Attribute(DamMStabAssembler.XmlAttributeMStabFileName);
-// Debug.Assert(mstabFileName != null, "mstabFileName != null");
-// mstabFileName.Value = stiFileName;
-//
-// // modify name of Soil DB Name
-// XAttribute dbName = inputElement.Attribute(DamMStabAssembler.XmlAttributeSoilDBName);
-// Debug.Assert(dbName != null, "dbName != null");
-// dbName.Value = soilDbName;
-//
-// // modify name of geometry input file
-// XElement geometryOptionsElement = (from element in inputElement.Descendants()
-// where element.Name.LocalName == DamMStabAssembler.XmlElementGeometryCreationOptions
-// select element).Single();
-// XAttribute geomFileName = geometryOptionsElement.Attribute(DamMStabAssembler.XmlAttributeSoilGeometry2DFilename);
-// Debug.Assert(geomFileName != null, "geomFileName != null");
-// geomFileName.Value = geometryFileName;
+ if (File.Exists(xmlFileName))
+ {
+ File.Delete(xmlFileName);
+ }
-
var line = FactoryForSurfaceLines.CreateSurfaceLineTutorial1();
var location = new Location();
var scenario = CreateScenarioForLocation(location, line);
@@ -101,19 +78,72 @@
failureMechanismeParamatersMStab.MStabParameters.SearchMethod = MStabSearchMethod.GeneticAlgorithm;
failureMechanismeParamatersMStab.MStabParameters.CalculationOptions.MinimalCircleDepth = 1.0;
- // ToDo mStabDesignEmbankment for now set to null
+ MStabDesignEmbankment mStabDesignEmbankment = null;
+
XDocument mstabXml = MStabXmlDoc.CreateMStabXmlDoc(stabilityProjectFilename, scenario, subSoilScenario,
- scenario.RiverLevel, null, surfaceLine, trafficLoad, requiredSafetyFactor, failureMechanismeParamatersMStab,
+ scenario.RiverLevel, mStabDesignEmbankment, surfaceLine, trafficLoad, requiredSafetyFactor, failureMechanismeParamatersMStab,
out errorMessages);
- mstabXml.Save(stabilityProjectFilename + ".xml");
- XElement inputElement = (from element in mstabXml.Root.Descendants()
+ mstabXml.Save(xmlFileName);
+ Assert.IsTrue(File.Exists(xmlFileName));
+ CompareByLine(ModifiedXmlDocument(expectedxmlFileName), ModifiedXmlDocument(xmlFileName));
+ }
+
+ private void CompareByLine(XDocument expectedXmlDocument, XDocument xmlDocument)
+ {
+ string expectedText = expectedXmlDocument.ToString();
+ string testedText = xmlDocument.ToString();
+ Assert.AreEqual(expectedText, testedText);
+ }
+
+ public XDocument ModifiedXmlDocument(string xmlFileName)
+ {
+ XDocument xDocument = XDocument.Load(xmlFileName);
+
+ // Modify FileIdentification
+ const string fileIdentificationElementName = "FileIdentification";
+ XElement fileIdentificationElement = (from element in xDocument.Root.Descendants()
+ where element.Name.LocalName == fileIdentificationElementName
+ select element).Single();
+
+ // clear application that created the xml
+ XAttribute application = fileIdentificationElement.Attribute("Application");
+ Debug.Assert(application != null, "application != null");
+ application.Value = "";
+
+ // clear version of application that created the xml
+ XAttribute version = fileIdentificationElement.Attribute("Version");
+ Debug.Assert(version != null, "version != null");
+ version.Value = "";
+
+ // clear creation date and time
+ XAttribute created = fileIdentificationElement.Attribute("Created");
+ Debug.Assert(created != null, "created != null");
+ created.Value = "";
+
+ // Modify DamMStabInput
+ XElement inputElement = (from element in xDocument.Root.Descendants()
where element.Name.LocalName == DamMStabAssembler.XmlElementNameInput
select element).Single();
- var attribute = inputElement.Attribute(DamMStabAssembler.XmlAttributeMStabFileName);
- Assert.IsNotNull(attribute);
- Assert.AreEqual(stabilityProjectFilename, attribute.Value);
+ // clear name of output sti file
+ XAttribute mstabFileName = inputElement.Attribute(DamMStabAssembler.XmlAttributeMStabFileName);
+ Debug.Assert(mstabFileName != null, "mstabFileName != null");
+ mstabFileName.Value = "";
+
+ // clear name of soil database
+ XAttribute dbName = inputElement.Attribute(DamMStabAssembler.XmlAttributeSoilDBName);
+ Debug.Assert(dbName != null, "dbName != null");
+ dbName.Value = "";
+
+ // clear name of geometry input file
+ XElement geometryOptionsElement = (from element in inputElement.Descendants()
+ where element.Name.LocalName == DamMStabAssembler.XmlElementGeometryCreationOptions
+ select element).Single();
+ XAttribute geomFileName = geometryOptionsElement.Attribute(DamMStabAssembler.XmlAttributeSoilGeometry2DFilename);
+ Debug.Assert(geomFileName != null, "geomFileName != null");
+ geomFileName.Value = "";
+ return xDocument;
}
public static DesignScenario CreateScenarioForLocation(Location location, SurfaceLine2 surfaceLine)