Index: DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/CalculationParametersAssembler.cs
===================================================================
diff -u -r3696 -r3697
--- DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/CalculationParametersAssembler.cs (.../CalculationParametersAssembler.cs) (revision 3696)
+++ DamClients/DamLive/trunk/src/Deltares.Dam.Application.Live/CalculationParametersAssembler.cs (.../CalculationParametersAssembler.cs) (revision 3697)
@@ -225,7 +225,7 @@
XmlSchemaSet schemas = new XmlSchemaSet();
- Stream xsdStream = Common.GetEmbeddedFile(Assembly.GetExecutingAssembly(), XsdEmbeddedResourcePath);
+ Stream xsdStream = Common.GetEmbeddedFile(Assembly.GetAssembly(typeof(TimeSeriesAssembler)), XsdEmbeddedResourcePath);
schemas.Add(XmlElementNamespace, XmlReader.Create(xsdStream));
doc.Validate(schemas, (o, e) => { result = false; errorMessage = e.Message; }, true);
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/CalculationParametersAssemblerTest.cs
===================================================================
diff -u
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/CalculationParametersAssemblerTest.cs (revision 0)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/CalculationParametersAssemblerTest.cs (revision 3697)
@@ -0,0 +1,127 @@
+// Copyright (C) Stichting Deltares 2019. All rights reserved.
+//
+// This file is part of the application DAM - UI.
+//
+// DAM - UI is free software: you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation, either version 3 of the License, or
+// (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program. If not, see .
+//
+// All names, logos, and references to "Deltares" are registered trademarks of
+// Stichting Deltares and remain full property of Stichting Deltares at all times.
+// All rights reserved.
+
+using System;
+using System.IO;
+using System.Xml.Linq;
+using Deltares.Dam.Application.Live;
+using Deltares.Dam.Data;
+using Deltares.DamLive.TestHelper;
+using Deltares.Standard;
+using NUnit.Framework;
+
+namespace Deltares.DamLive.Tests
+{
+
+ [TestFixture]
+ public class CalculationParametersAssemblerTest
+ {
+ private const string testFileName = @"TestData\SampleCalculationParameters.xml";
+ private const double Precision = 1e-8;
+ private XDocument testDoc;
+ private CalculationParametersAssembler assembler;
+
+
+ #region Setup/Teardown
+
+ [SetUp]
+ public void TestSetup()
+ {
+ this.assembler = new CalculationParametersAssembler();
+ }
+
+ #endregion
+
+ [TestFixtureSetUp]
+ public void TestFixtureSetup()
+ {
+ this.testDoc = XDocument.Load(testFileName);
+ }
+
+ [Test]
+ [TestCase("PipingSellmeijerProbabilistic")]
+ [TestCase("PipingIJkdijk")]
+ [TestCase("Overtopping")]
+ public void GivenParameterFileWithObsoleteCalculationModuleWhenParsingThenExceptionIsThrown(string obsoleteElement)
+ {
+ // Given ParameterFile with obsolete Calculation Module
+ string inputString = File.ReadAllText(testFileName);
+ inputString = XmlAdapter.ChangeKeyName(inputString, "StabilityOutside", obsoleteElement);
+ XDocument inputDocument = XDocument.Parse(inputString);
+
+ // When parsing, then exception is thrown
+ Assert.That(() => this.assembler.CreateDomainObject(inputDocument),
+ Throws.TypeOf(typeof(DtoAssemblerException)).With.Message.EqualTo(
+ String.Format("Your input file is incorrect. The specified parameter '{0}' in your xml is obsolete. Please remove it.", obsoleteElement)));
+ }
+
+ [Test]
+ [TestCase("ShearStrength")]
+ [TestCase("Probabilistic")]
+ [TestCase("IsOverrulePLLineCreationMethod")]
+ [TestCase("PLLineCreationMethod")]
+ public void GivenParameterFileWithObsoleteMStabParametersWhenParsingThenExceptionIsThrown(string obsoleteElement)
+ {
+ // Given ParameterFile with obsolete MStab parameters
+ string inputString = File.ReadAllText(testFileName);
+ inputString = XmlAdapter.ChangeKeyName(inputString, "CalculationModel", obsoleteElement);
+ XDocument inputDocument = XDocument.Parse(inputString);
+
+ // When parsing, then exception is thrown
+ Assert.That(() => this.assembler.CreateDomainObject(inputDocument),
+ Throws.TypeOf(typeof(DtoAssemblerException)).With.Message.EqualTo(
+ String.Format("Your input file is incorrect. The specified parameter '{0}' in your xml is obsolete. Please remove it.", obsoleteElement)));
+ }
+
+ [Test]
+ public void CreateEntityFromDto()
+ {
+ // First validate test XML against schema
+ string message;
+ if (!this.assembler.ValidateSchema(this.testDoc, out message))
+ {
+ Assert.Fail("SCHEMA VALIDATION: " + message);
+ }
+
+ // Do the thing: create MStabParameters from XML element
+ CalculationParameters calculationParameters = this.assembler.CreateDomainObject(this.testDoc);
+
+ Assert.IsNotNull(calculationParameters);
+
+ // Calculation modules
+ Assert.IsNotNull(calculationParameters.CalculationModules);
+
+ Assert.IsTrue(calculationParameters.CalculationModules.StabilityOutside, "CalculationModules.StabilityOutside");
+ Assert.IsTrue(calculationParameters.CalculationModules.StabilityInside, "CalculationModules.Stability");
+ Assert.IsTrue(calculationParameters.CalculationModules.PipingWti, "CalculationModules.PipingWti");
+ Assert.IsTrue(calculationParameters.CalculationModules.PipingBligh, "CalculationModules.PipingBligh");
+ Assert.IsTrue(calculationParameters.CalculationModules.PipingSellmeijer, "CalculationModules.PipingSellmeijer");
+
+ // MStab parameters
+ Assert.IsNotNull(calculationParameters.MStabParameters);
+
+ Assert.AreEqual(false, calculationParameters.MStabParameters.IsCalculateAllStabilityProjectsAtOnce, "MStabParameters.IsCalculateAllStabilityProjectsAtOnce");
+ Assert.AreEqual(MStabModelType.UpliftVan, calculationParameters.MStabParameters.Model, "MStabParameters.Model");
+ Assert.AreEqual(MStabSearchMethod.Grid, calculationParameters.MStabParameters.SearchMethod, "MStabParameters.SearchMethod");
+ Assert.IsTrue(calculationParameters.MStabParameters.CalculationOptions.ZonesType.Equals(MStabZonesType.ForbiddenZone), "MStabParameters.CalculationOptions.ZonesType");
+ }
+ }
+}
\ No newline at end of file
Index: DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/Deltares.DamLive.Tests.csproj
===================================================================
diff -u -r3449 -r3697
--- DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/Deltares.DamLive.Tests.csproj (.../Deltares.DamLive.Tests.csproj) (revision 3449)
+++ DamClients/DamLive/trunk/src/Deltares.DamLive.Tests/Deltares.DamLive.Tests.csproj (.../Deltares.DamLive.Tests.csproj) (revision 3697)
@@ -53,6 +53,7 @@
+
@@ -183,6 +184,9 @@
PreserveNewest
+
+ PreserveNewest
+
+
+
+ 1
+ 1
+ 1
+ 1
+ 1
+
+
+ 0
+ Grid
+ 1
+ UpliftVan
+
+
\ No newline at end of file