Index: dam engine/trunk/src/Deltares.DamEngine.Data.Tests/Properties/AssemblyInfo.cs =================================================================== diff -u --- dam engine/trunk/src/Deltares.DamEngine.Data.Tests/Properties/AssemblyInfo.cs (revision 0) +++ dam engine/trunk/src/Deltares.DamEngine.Data.Tests/Properties/AssemblyInfo.cs (revision 643) @@ -0,0 +1,36 @@ +using System.Reflection; +using System.Runtime.CompilerServices; +using System.Runtime.InteropServices; + +// General Information about an assembly is controlled through the following +// set of attributes. Change these attribute values to modify the information +// associated with an assembly. +[assembly: AssemblyTitle("Deltares.DamEngine.Data.Tests")] +[assembly: AssemblyDescription("")] +[assembly: AssemblyConfiguration("")] +[assembly: AssemblyCompany("Microsoft")] +[assembly: AssemblyProduct("Deltares.DamEngine.Data.Tests")] +[assembly: AssemblyCopyright("Copyright © Microsoft 2017")] +[assembly: AssemblyTrademark("")] +[assembly: AssemblyCulture("")] + +// Setting ComVisible to false makes the types in this assembly not visible +// to COM components. If you need to access a type in this assembly from +// COM, set the ComVisible attribute to true on that type. +[assembly: ComVisible(false)] + +// The following GUID is for the ID of the typelib if this project is exposed to COM +[assembly: Guid("b8bd3348-ee6e-4baa-bc0f-2554a916ebb6")] + +// Version information for an assembly consists of the following four values: +// +// Major Version +// Minor Version +// Build Number +// Revision +// +// You can specify all the values or you can default the Build and Revision Numbers +// by using the '*' as shown below: +// [assembly: AssemblyVersion("1.0.*")] +[assembly: AssemblyVersion("1.0.0.0")] +[assembly: AssemblyFileVersion("1.0.0.0")] Fisheye: Tag 643 refers to a dead (removed) revision in file `dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/DamMacroStabilityTests.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: dam classic/trunk/src/Dam/Data/Deltares.Dam.Data.csproj =================================================================== diff -u -r500 -r643 --- dam classic/trunk/src/Dam/Data/Deltares.Dam.Data.csproj (.../Deltares.Dam.Data.csproj) (revision 500) +++ dam classic/trunk/src/Dam/Data/Deltares.Dam.Data.csproj (.../Deltares.Dam.Data.csproj) (revision 643) @@ -441,7 +441,6 @@ SoilProfileDataSet.xsd - Component SoilProfileDataSet.cs Index: dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/DamMacroStabilityKernelWrapperTests.cs =================================================================== diff -u --- dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/DamMacroStabilityKernelWrapperTests.cs (revision 0) +++ dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamMacroStability/DamMacroStabilityKernelWrapperTests.cs (revision 643) @@ -0,0 +1,218 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of the Dam Engine. +// +// The Dam Engine is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero 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.Collections.Generic; +using System.Data; +using System.Diagnostics; +using System.IO; +using System.Linq; +using System.Xml.Linq; +using Deltares.DamEngine.Calculators.KernelWrappers.Common; +using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStability; +using Deltares.DamEngine.Calculators.KernelWrappers.DamMacroStability.Assemblers; +using Deltares.DamEngine.Data.General.Results; +using Deltares.DamEngine.Data.Standard.Logging; +using NUnit.Framework; + +namespace Deltares.DamEngine.Calculators.Tests +{ + [TestFixture] + public class DamMacroStabilityTests + { + [Test] + public void TestFullCalculation() + { + const double diff = 0.01; + + // ToDo zant Fill input + var damKernelInput = new DamKernelInput(); + + var kernelWrapper = new DamMacroStabilityKernelWrapper(); + + // Prepare the wrapper. Result is input for the calculation dll + var damStabilityInput = kernelWrapper.Prepare(damKernelInput); + + // Validate the input + List messages; + kernelWrapper.Validate(damStabilityInput, out messages); + Assert.AreEqual(0, messages.Count); + + // Run the dll + DamMacroStabilityOutput output = (DamMacroStabilityOutput)kernelWrapper.Execute(damStabilityInput, out messages); + Assert.AreEqual(0, messages.Count); + Assert.AreEqual(1.71, output.Zone1.SafetyFactor, diff); + Assert.IsNull(output.Zone2); + + // Fill the design results + DesignResult result; + kernelWrapper.PostProcess(damKernelInput, output, out result); + Assert.AreEqual(1.71, result.StabilityDesignResults.SafetyFactor, diff); + } + + [Test] + public void TestCreateDGeoStabilityInputFile() + { + const string testFolder = @"..\..\Deltares.DamEngine.Calculators.Tests\Files\MacroStability"; + 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; + + var kernelWrapper = new DamMacroStabilityKernelWrapper(); + kernelWrapper.CreateStiFile(xDocument); + Assert.IsTrue(File.Exists(stiFileName)); + Assert.AreEqual(ContentOfStiFile(expectedStiFileName), ContentOfStiFile(stiFileName)); + } + + [Test] + [ExpectedException(typeof(MacroStabilityException))] + public void TestThrowsExceptionXmlFileNotValid() + { + var kernelWrapper = new DamMacroStabilityKernelWrapper(); + XDocument xDocument = new XDocument(); + kernelWrapper.CreateStiFile(xDocument); + } + + + private string ContentOfStiFile(string stiFileName) + { + try + { + StreamReader stream = File.OpenText(stiFileName); + for (int i = 1; i <= 7; i++) + { + stream.ReadLine(); // skip first 7 lines with date, time and filename + } + string text = stream.ReadToEnd(); + stream.Close(); + return text; + } + catch + { + return null; + } + } + + [Test] + public void TestValidate() + { + var kernelWrapper = new DamMacroStabilityKernelWrapper(); + + // Validate without setting values. Expected error messages. + var damStabilityInput = new DamMacroStabilityInput(); + List messages; + // Validate is not implemented (yet), returns always true + // kernelWrapper.Validate(damStabilityInput, out messages); + // Assert.IsTrue(messages.Count > 0); + + // Validate the input when valid input is provided. Expected no messages. + damStabilityInput = new DamMacroStabilityInput + { + // ToDo zant Fill input + }; +// messages.Clear(); + kernelWrapper.Validate(damStabilityInput, out messages); + Assert.AreEqual(0, messages.Count); + } + + [Test] + public void TestPostProcess() + { + var kernelWrapper = new DamMacroStabilityKernelWrapper(); + + DamMacroStabilityOutput output = new DamMacroStabilityOutput(); + var zone1 = new DamMacroStabilityOutput.ResultsSingleZone(); + zone1.SafetyFactor = 1.1; + zone1.EntryPointXCoordinate = 1.2; + zone1.ExitPointXCoordinate = 1.3; + output.Zone1 = zone1; + var zone2 = new DamMacroStabilityOutput.ResultsSingleZone(); + zone2.SafetyFactor = 0.9; + zone2.EntryPointXCoordinate = 2.2; + zone2.ExitPointXCoordinate = 2.3; + output.Zone2 = zone2; + + DesignResult result; + kernelWrapper.PostProcess(null, output, out result); + Assert.AreEqual(0.9, result.StabilityDesignResults.SafetyFactor); + Assert.AreEqual(1.1, result.StabilityDesignResults.Zone1SafetyFactor); + Assert.AreEqual(1.2, result.StabilityDesignResults.LocalZone1EntryPointX); + Assert.AreEqual(1.3, result.StabilityDesignResults.LocalZone1ExitPointX); + Assert.AreEqual(0.9, result.StabilityDesignResults.Zone2SafetyFactor); + Assert.AreEqual(2.2, result.StabilityDesignResults.LocalZone2EntryPointX); + Assert.AreEqual(2.3, result.StabilityDesignResults.LocalZone2ExitPointX); + } + + [Test] + [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen invoer object gedefinieerd voor Macrostabiliteit")] + [SetUICulture("nl-NL")] + public void TestLanguageNLThrowsExceptionWhenInputIsNull() + { + DamMacroStabilityKernelWrapper.StabilityCalculator(null); + } + + [Test] + [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "No input object defined for Macro Stability")] + [SetUICulture("en-US")] + public void TestLanguageENThrowsExceptionWhenInputIsNull() + { + DamMacroStabilityKernelWrapper.StabilityCalculator(null); + } + + [Test] + [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen uitvoer object gedefinieerd voor Macrostabiliteit")] + [SetUICulture("nl-NL")] + public void TestThrowsExceptionWhenOutputIsNull() + { + var kernelWrapper = new DamMacroStabilityKernelWrapper(); + DesignResult result; + kernelWrapper.PostProcess(null, null, out result); + } + + } +} Fisheye: Tag 643 refers to a dead (removed) revision in file `dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/DamPipingSellmeijer4ForcesTests.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj =================================================================== diff -u -r583 -r643 --- dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 583) +++ dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/Deltares.DamEngine.Calculators.Tests.csproj (.../Deltares.DamEngine.Calculators.Tests.csproj) (revision 643) @@ -44,8 +44,8 @@ - - + + Index: dam engine/trunk/src/DamEngine.sln =================================================================== diff -u -r511 -r643 --- dam engine/trunk/src/DamEngine.sln (.../DamEngine.sln) (revision 511) +++ dam engine/trunk/src/DamEngine.sln (.../DamEngine.sln) (revision 643) @@ -22,62 +22,49 @@ {E943B1D5-FAFA-4AFE-9071-F8B22CF612EA} = {E943B1D5-FAFA-4AFE-9071-F8B22CF612EA} EndProjectSection EndProject +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Deltares.DamEngine.Data.Tests", "Deltares.DamEngine.Data.Tests\Deltares.DamEngine.Data.Tests.csproj", "{B8BD3348-EE6E-4BAA-BC0F-2554A916EBB6}" + ProjectSection(ProjectDependencies) = postProject + {B7A49C1A-1C91-4D72-ABA9-9FBAC2509D8E} = {B7A49C1A-1C91-4D72-ABA9-9FBAC2509D8E} + EndProjectSection +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU Debug|x86 = Debug|x86 - Release|Any CPU = Release|Any CPU Release|x86 = Release|x86 EndGlobalSection GlobalSection(ProjectConfigurationPlatforms) = postSolution - {750464A3-CBFA-429F-920E-B430867F1120}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {750464A3-CBFA-429F-920E-B430867F1120}.Debug|Any CPU.Build.0 = Debug|Any CPU {750464A3-CBFA-429F-920E-B430867F1120}.Debug|x86.ActiveCfg = Debug|x86 {750464A3-CBFA-429F-920E-B430867F1120}.Debug|x86.Build.0 = Debug|x86 - {750464A3-CBFA-429F-920E-B430867F1120}.Release|Any CPU.ActiveCfg = Release|Any CPU - {750464A3-CBFA-429F-920E-B430867F1120}.Release|Any CPU.Build.0 = Release|Any CPU {750464A3-CBFA-429F-920E-B430867F1120}.Release|x86.ActiveCfg = Release|x86 {750464A3-CBFA-429F-920E-B430867F1120}.Release|x86.Build.0 = Release|x86 - {968516F9-1B92-4ADB-AE4A-CFF54EE43126}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {968516F9-1B92-4ADB-AE4A-CFF54EE43126}.Debug|Any CPU.Build.0 = Debug|Any CPU {968516F9-1B92-4ADB-AE4A-CFF54EE43126}.Debug|x86.ActiveCfg = Debug|x86 {968516F9-1B92-4ADB-AE4A-CFF54EE43126}.Debug|x86.Build.0 = Debug|x86 - {968516F9-1B92-4ADB-AE4A-CFF54EE43126}.Release|Any CPU.ActiveCfg = Release|Any CPU - {968516F9-1B92-4ADB-AE4A-CFF54EE43126}.Release|Any CPU.Build.0 = Release|Any CPU {968516F9-1B92-4ADB-AE4A-CFF54EE43126}.Release|x86.ActiveCfg = Release|x86 {968516F9-1B92-4ADB-AE4A-CFF54EE43126}.Release|x86.Build.0 = Release|x86 - {E943B1D5-FAFA-4AFE-9071-F8B22CF612EA}.Debug|Any CPU.ActiveCfg = Debug|x86 {E943B1D5-FAFA-4AFE-9071-F8B22CF612EA}.Debug|x86.ActiveCfg = Debug|x86 {E943B1D5-FAFA-4AFE-9071-F8B22CF612EA}.Debug|x86.Build.0 = Debug|x86 - {E943B1D5-FAFA-4AFE-9071-F8B22CF612EA}.Release|Any CPU.ActiveCfg = Release|x86 {E943B1D5-FAFA-4AFE-9071-F8B22CF612EA}.Release|x86.ActiveCfg = Release|x86 {E943B1D5-FAFA-4AFE-9071-F8B22CF612EA}.Release|x86.Build.0 = Release|x86 - {B7A49C1A-1C91-4D72-ABA9-9FBAC2509D8E}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B7A49C1A-1C91-4D72-ABA9-9FBAC2509D8E}.Debug|Any CPU.Build.0 = Debug|Any CPU {B7A49C1A-1C91-4D72-ABA9-9FBAC2509D8E}.Debug|x86.ActiveCfg = Debug|x86 {B7A49C1A-1C91-4D72-ABA9-9FBAC2509D8E}.Debug|x86.Build.0 = Debug|x86 - {B7A49C1A-1C91-4D72-ABA9-9FBAC2509D8E}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B7A49C1A-1C91-4D72-ABA9-9FBAC2509D8E}.Release|Any CPU.Build.0 = Release|Any CPU {B7A49C1A-1C91-4D72-ABA9-9FBAC2509D8E}.Release|x86.ActiveCfg = Release|x86 {B7A49C1A-1C91-4D72-ABA9-9FBAC2509D8E}.Release|x86.Build.0 = Release|x86 - {9CB1ECCE-2F86-418D-BBDC-166BD1FB7F57}.Debug|Any CPU.ActiveCfg = Debug|x86 {9CB1ECCE-2F86-418D-BBDC-166BD1FB7F57}.Debug|x86.ActiveCfg = Debug|x86 {9CB1ECCE-2F86-418D-BBDC-166BD1FB7F57}.Debug|x86.Build.0 = Debug|x86 - {9CB1ECCE-2F86-418D-BBDC-166BD1FB7F57}.Release|Any CPU.ActiveCfg = Release|x86 {9CB1ECCE-2F86-418D-BBDC-166BD1FB7F57}.Release|x86.ActiveCfg = Release|x86 {9CB1ECCE-2F86-418D-BBDC-166BD1FB7F57}.Release|x86.Build.0 = Release|x86 - {1560A423-F338-4DEC-8583-1DFF7077F104}.Debug|Any CPU.ActiveCfg = Debug|x86 {1560A423-F338-4DEC-8583-1DFF7077F104}.Debug|x86.ActiveCfg = Debug|x86 {1560A423-F338-4DEC-8583-1DFF7077F104}.Debug|x86.Build.0 = Debug|x86 - {1560A423-F338-4DEC-8583-1DFF7077F104}.Release|Any CPU.ActiveCfg = Release|x86 {1560A423-F338-4DEC-8583-1DFF7077F104}.Release|x86.ActiveCfg = Release|x86 {1560A423-F338-4DEC-8583-1DFF7077F104}.Release|x86.Build.0 = Release|x86 - {783E7BC6-CD3F-4851-B5EF-46DE954AACD1}.Debug|Any CPU.ActiveCfg = Debug|x86 {783E7BC6-CD3F-4851-B5EF-46DE954AACD1}.Debug|x86.ActiveCfg = Debug|x86 {783E7BC6-CD3F-4851-B5EF-46DE954AACD1}.Debug|x86.Build.0 = Debug|x86 - {783E7BC6-CD3F-4851-B5EF-46DE954AACD1}.Release|Any CPU.ActiveCfg = Release|x86 {783E7BC6-CD3F-4851-B5EF-46DE954AACD1}.Release|x86.ActiveCfg = Release|x86 {783E7BC6-CD3F-4851-B5EF-46DE954AACD1}.Release|x86.Build.0 = Release|x86 + {B8BD3348-EE6E-4BAA-BC0F-2554A916EBB6}.Debug|x86.ActiveCfg = Debug|x86 + {B8BD3348-EE6E-4BAA-BC0F-2554A916EBB6}.Debug|x86.Build.0 = Debug|x86 + {B8BD3348-EE6E-4BAA-BC0F-2554A916EBB6}.Release|x86.ActiveCfg = Release|x86 + {B8BD3348-EE6E-4BAA-BC0F-2554A916EBB6}.Release|x86.Build.0 = Release|x86 EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -86,5 +73,6 @@ {968516F9-1B92-4ADB-AE4A-CFF54EE43126} = {3888E604-1A01-474C-885B-B9BBC19054D4} {9CB1ECCE-2F86-418D-BBDC-166BD1FB7F57} = {3888E604-1A01-474C-885B-B9BBC19054D4} {783E7BC6-CD3F-4851-B5EF-46DE954AACD1} = {3888E604-1A01-474C-885B-B9BBC19054D4} + {B8BD3348-EE6E-4BAA-BC0F-2554A916EBB6} = {3888E604-1A01-474C-885B-B9BBC19054D4} EndGlobalSection EndGlobal Index: dam engine/trunk/src/Deltares.DamEngine.Data.Tests/Deltares.DamEngine.Data.Tests.csproj =================================================================== diff -u --- dam engine/trunk/src/Deltares.DamEngine.Data.Tests/Deltares.DamEngine.Data.Tests.csproj (revision 0) +++ dam engine/trunk/src/Deltares.DamEngine.Data.Tests/Deltares.DamEngine.Data.Tests.csproj (revision 643) @@ -0,0 +1,55 @@ + + + + + Debug + AnyCPU + {B8BD3348-EE6E-4BAA-BC0F-2554A916EBB6} + Library + Properties + Deltares.DamEngine.Data.Tests + Deltares.DamEngine.Data.Tests + v4.5 + 512 + + + true + ..\bin\Debug\ + DEBUG;TRACE + full + x86 + prompt + MinimumRecommendedRules.ruleset + + + ..\bin\Release\ + TRACE + true + pdbonly + x86 + prompt + MinimumRecommendedRules.ruleset + + + + + + + + + + + + + + + + + + \ No newline at end of file Index: dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamPipingSellmeijer4Forces/DamPipingSellmeijer4ForcesKernelWrapperTests.cs =================================================================== diff -u --- dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamPipingSellmeijer4Forces/DamPipingSellmeijer4ForcesKernelWrapperTests.cs (revision 0) +++ dam engine/trunk/src/Deltares.DamEngine.Calculators.Tests/KernelWrappers/DamPipingSellmeijer4Forces/DamPipingSellmeijer4ForcesKernelWrapperTests.cs (revision 643) @@ -0,0 +1,280 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of the Dam Engine. +// +// The Dam Engine is free software: you can redistribute it and/or modify +// it under the terms of the GNU Affero 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 Affero General Public License for more details. +// +// You should have received a copy of the GNU Affero 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.Collections.Generic; +using System.Data; +using Deltares.DamEngine.Calculators.KernelWrappers.Common; +using Deltares.DamEngine.Calculators.KernelWrappers.DamPipingSellmeijer4Forces; +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.Logging; +using NUnit.Framework; + +namespace Deltares.DamEngine.Calculators.Tests +{ + [TestFixture] + public class DamPipingSellmeijer4ForcesTests + { + + [Test] + public void TestFullCalculation() + { + // expected results are based on test in 'https://repos.deltares.nl/repos/dam/dam classic' revision 190 + // reducedFall = HRiver - HExit - (Rc * DTotal) = 1.0 - 0.0 - (0.3 * 2.0) = 0.4 + // FoSp = Hc / reducedFall = 4.7596 / 0.4 = 11.899 + // For calculation of Hc see TestCanCalculateHCritical + // See also "..\..\doc\Evaluation Piping\Nieuwe rekenregel bligh Sellmeijeruli.xls" + + const double diff = 0.0001; + + var designScenario = new DesignScenario(); + designScenario.Location = new Location(); + designScenario.RiverLevel = 1.0; + designScenario.ModelFactors.UpliftCriterionPiping = 1.0; + + var location = new Location(); + location.SurfaceLine = CreateSurfaceLineTutorial1(); + + var subSoilScenario = new SoilGeometryProbability(); + subSoilScenario.SoilProfile1D = CreatePipingSellmeijerProfileWithOneSandlayer(); + + var damKernelInput = new DamKernelInput + { + DesignScenario = designScenario, + Location = location, + SubSoilScenario = subSoilScenario + }; + + var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); + + // Prepare the wrapper. Result is input for the calculation dll + var damPipingInput = kernelWrapper.Prepare(damKernelInput); + + // Validate the input + List messages; + kernelWrapper.Validate(damPipingInput, out messages); + Assert.AreEqual(0, messages.Count); + + // Run the dll + DamPipingSellmeijer4ForcesOutput output = (DamPipingSellmeijer4ForcesOutput) kernelWrapper.Execute(damPipingInput, out messages); + Assert.AreEqual(0, messages.Count); + Assert.AreEqual(11.899117458988471, output.FoSp, diff); + Assert.AreEqual(4.7596469835953883, output.Hc, diff); + + // Fill the design results + DesignResult result; + kernelWrapper.PostProcess(damKernelInput, output, out result); + Assert.AreEqual(11.899117458988471, result.PipingDesignResults.Sellmeijer4ForcesFactor, diff); + Assert.AreEqual(4.7596469835953883, result.PipingDesignResults.Sellmeijer4ForcesHcritical, diff); + } + + [Test] + public void TestPrepare() + { + const double diff = 0.0001; + + var designScenario = new DesignScenario(); + designScenario.Location = new Location(); + designScenario.RiverLevel = 1.0; + designScenario.ModelFactors.UpliftCriterionPiping = 1.0; + + var location = new Location(); + location.SurfaceLine = CreateSurfaceLineTutorial1(); + + var subSoilScenario = new SoilGeometryProbability(); + subSoilScenario.SoilProfile1D = CreatePipingSellmeijerProfileWithOneSandlayer(); + + var damKernelInput = new DamKernelInput + { + DesignScenario = designScenario, + Location = location, + SubSoilScenario = subSoilScenario + }; + var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); + var damPipingInput = (DamPipingSellmeijer4ForcesInput)kernelWrapper.Prepare(damKernelInput); + Assert.AreEqual(1.0, damPipingInput.HRiver, diff); + Assert.AreEqual(0.0, damPipingInput.HExit, diff); + Assert.AreEqual(0.3, damPipingInput.Rc, diff); + Assert.AreEqual(2.0, damPipingInput.DTotal, diff); + Assert.AreEqual(8.0, damPipingInput.AquiferHeight, diff); + Assert.AreEqual(40.5, damPipingInput.SeepageLength, diff); + Assert.AreEqual(200.0, damPipingInput.D70, diff); + Assert.AreEqual(0.25, damPipingInput.WhitesConstant, diff); + Assert.AreEqual(37.0, damPipingInput.BeddingAngle, diff); + Assert.AreEqual(1.33E-06, damPipingInput.WaterViscosity, diff); + Assert.AreEqual(0.0001, damPipingInput.PermeabilityKx, diff); + } + + [Test] + public void TestValidate() + { + var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); + + // Validate without setting values. Expected error messages. + var damPipingInput = new DamPipingSellmeijer4ForcesInput(); + List messages; + kernelWrapper.Validate(damPipingInput, out messages); + Assert.IsTrue(messages.Count > 0); + + // Validate the input when valid input is provided. Expected no messages. + damPipingInput = new DamPipingSellmeijer4ForcesInput + { + HRiver = 1.0, + HExit = 0.0, + Rc = 0.3, + DTotal = 2.0, + AquiferHeight = 8.0, + SeepageLength = 40.5, + D70 = 200.0, + WhitesConstant = 0.25, + BeddingAngle = 37.0, + WaterViscosity = 1.33E-06, + PermeabilityKx = 0.0001 + }; + messages.Clear(); + kernelWrapper.Validate(damPipingInput, out messages); + Assert.AreEqual(0, messages.Count); + } + + [Test] + public void TestPostProcess() + { + var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); + + var input = new DamKernelInput + { + DesignScenario = new DesignScenario(), + Location = new Location(), + SubSoilScenario = new SoilGeometryProbability() + }; + input.DesignScenario.Location = new Location(); + + DamPipingSellmeijer4ForcesOutput output = new DamPipingSellmeijer4ForcesOutput + { + FoSp = 1.1, + Hc = 2.2 + }; + + DesignResult result; + kernelWrapper.PostProcess(input, output, out result); + Assert.AreEqual(output.FoSp, result.PipingDesignResults.Sellmeijer4ForcesFactor); + Assert.AreEqual(output.Hc, result.PipingDesignResults.Sellmeijer4ForcesHcritical); + } + + [Test] + [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen invoer object gedefinieerd voor Sellmeijer 4 Krachten")] + [SetUICulture("nl-NL")] + public void TestLanguageNLThrowsExceptionInExecuteWhenInputIsNull() + { + var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); + List messages; + kernelWrapper.Execute(null, out messages); + } + + [Test] + [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "No input object defined for Sellmeijer 4 Forces")] + [SetUICulture("en-US")] + public void TestLanguageENThrowsExceptionInExecuteWhenInputIsNull() + { + var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); + List messages; + kernelWrapper.Execute(null, out messages); + } + + [Test] + [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen uitvoer object gedefinieerd voor Sellmeijer 4 Krachten")] + [SetUICulture("nl-NL")] + public void TestThrowsExceptionInPostProcessWhenOutputIsNull() + { + var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); + DesignResult result; + kernelWrapper.PostProcess(new DamKernelInput(), null, out result); + } + + [Test] + [ExpectedException(typeof(NoNullAllowedException), ExpectedMessage = "Geen invoer object gedefinieerd voor Sellmeijer 4 Krachten")] + [SetUICulture("nl-NL")] + public void TestThrowsExceptionInPostProcessWhenInputIsNull() + { + var kernelWrapper = new DamPipingSellmeijer4ForcesKernelWrapper(); + DesignResult result; + kernelWrapper.PostProcess(null, new DamPipingSellmeijer4ForcesOutput(), out result); + } + + public static SoilProfile1D CreatePipingSellmeijerProfileWithOneSandlayer() + { + SoilProfile1D soilProfile1D = new SoilProfile1D(); + SoilLayer1D soilLayer1D1 = new SoilLayer1D(); + soilLayer1D1.Name = "L0"; + soilLayer1D1.TopLevel = 10.0; + soilLayer1D1.Soil = new Soil("Topmaterial", 1.0, 1.0); + soilLayer1D1.Soil.PermeabKx = 0.0003; + soilLayer1D1.Soil.DiameterD70 = 0.0003; + soilLayer1D1.Soil.WhitesConstant = 0.5; + soilLayer1D1.Soil.BeddingAngle = 57.0; + soilLayer1D1.IsAquifer = false; + soilProfile1D.Layers.Add(soilLayer1D1); + + SoilLayer1D soilLayer1D2 = new SoilLayer1D(); + soilLayer1D2.Name = "L1"; + soilLayer1D2.TopLevel = -2.0; + soilLayer1D2.Soil = new Soil("Sand", 22.0, 20.0); + soilLayer1D2.Soil.PermeabKx = 0.0001; + soilLayer1D2.Soil.DiameterD70 = 0.0002; + soilLayer1D2.Soil.WhitesConstant = 0.25; + soilLayer1D2.Soil.BeddingAngle = 37.0; + soilLayer1D2.IsAquifer = true; + soilProfile1D.Layers.Add(soilLayer1D2); + soilProfile1D.BottomLevel = -10.0; + return soilProfile1D; + } + + public static SurfaceLine2 CreateSurfaceLineTutorial1(bool includingTraffic = false) + { + SurfaceLine2 surfaceLine2 = new SurfaceLine2(); + surfaceLine2.Name = "Tutorial1"; + surfaceLine2.Geometry = new GeometryPointString(); + surfaceLine2.CharacteristicPoints.GeometryMustContainPoint = true; + SurfaceLine2 line = surfaceLine2; + line.EnsurePointOfType(0.0, 0.0, CharacteristicPointType.SurfaceLevelOutside); + line.EnsurePointOfType(10.0, 0.0, CharacteristicPointType.DikeToeAtRiver); + line.EnsurePointOfType(34.5, 5.0, CharacteristicPointType.DikeTopAtRiver); + if (includingTraffic) + { + line.EnsurePointOfType(35.0, 5.0, CharacteristicPointType.TrafficLoadOutside); + line.EnsurePointOfType(38.5, 5.0, CharacteristicPointType.TrafficLoadInside); + } + line.EnsurePointOfType(40.5, 5.0, CharacteristicPointType.DikeTopAtPolder); + line.EnsurePointOfType(50.5, 0.0, CharacteristicPointType.DikeToeAtPolder); + line.EnsurePointOfType(58.5, 0.0, CharacteristicPointType.DitchDikeSide); + line.EnsurePointOfType(59.5, -2.0, CharacteristicPointType.BottomDitchDikeSide); + line.EnsurePointOfType(61.5, -2.0, CharacteristicPointType.BottomDitchPolderSide); + line.EnsurePointOfType(61.5, 0.0, CharacteristicPointType.DitchPolderSide); + line.EnsurePointOfType(75.0, 0.0, CharacteristicPointType.SurfaceLevelInside); + line.Geometry.SyncCalcPoints(); + return line; + } + + } +} Index: dam engine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile1DAquiferLayerCombinerTests.cs =================================================================== diff -u --- dam engine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile1DAquiferLayerCombinerTests.cs (revision 0) +++ dam engine/trunk/src/Deltares.DamEngine.Data.Tests/Geotechnics/SoilProfile1DAquiferLayerCombinerTests.cs (revision 643) @@ -0,0 +1,12 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using System.Threading.Tasks; + +namespace Deltares.DamEngine.Data.Tests.Geotechnics +{ + public class SoilProfile1DAquiferLayerCombinerTests + { + } +}