Index: Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/HydraRingDataEqualityHelper.cs =================================================================== diff -u -r7a1b6072eb543968bd2d9b1a21c53572cd98b89a -r276a32161f29fcba4af79cf7c7f0aeb254d4db54 --- Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/HydraRingDataEqualityHelper.cs (.../HydraRingDataEqualityHelper.cs) (revision 7a1b6072eb543968bd2d9b1a21c53572cd98b89a) +++ Ringtoets/HydraRing/test/Ringtoets.HydraRing.Calculation.TestUtil/HydraRingDataEqualityHelper.cs (.../HydraRingDataEqualityHelper.cs) (revision 276a32161f29fcba4af79cf7c7f0aeb254d4db54) @@ -100,6 +100,28 @@ AreEqual(expectedInput.Variables.ToArray(), actualInput.Variables.ToArray()); } + /// + /// Asserts whether or not and are equal to eachother. + /// + /// The expected calculation input. + /// The actual calculation input. + public static void AreEqual(StructuresStabilityPointCalculationInput expectedInput, StructuresStabilityPointCalculationInput actualInput) + { + Assert.AreEqual(expectedInput.FailureMechanismType, actualInput.FailureMechanismType); + Assert.AreEqual(expectedInput.CalculationTypeId, actualInput.CalculationTypeId); + Assert.AreEqual(expectedInput.VariableId, actualInput.VariableId); + Assert.AreEqual(expectedInput.HydraulicBoundaryLocationId, actualInput.HydraulicBoundaryLocationId); + Assert.AreEqual(expectedInput.Section.SectionId, actualInput.Section.SectionId); + + Assert.AreEqual(expectedInput.Beta, actualInput.Beta, accuracy); + Assert.AreEqual(expectedInput.Section.CrossSectionNormal, actualInput.Section.CrossSectionNormal, accuracy); + + AreEqual(expectedInput.BreakWater, actualInput.BreakWater); + AreEqual(expectedInput.Section, actualInput.Section); + AreEqual(expectedInput.ForelandsPoints.ToArray(), actualInput.ForelandsPoints.ToArray()); + AreEqual(expectedInput.Variables.ToArray(), actualInput.Variables.ToArray()); + } + private static void AreEqual(HydraRingBreakWater expectedBreakWater, HydraRingBreakWater actualBreakWater) { if (expectedBreakWater == null) Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/Properties/Resources.Designer.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/Properties/Resources.Designer.cs (revision 0) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/Properties/Resources.Designer.cs (revision 276a32161f29fcba4af79cf7c7f0aeb254d4db54) @@ -0,0 +1,84 @@ +//------------------------------------------------------------------------------ +// +// This code was generated by a tool. +// Runtime Version:4.0.30319.17929 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// +//------------------------------------------------------------------------------ + +namespace Ringtoets.StabilityPointStructures.Service.Properties { + using System; + + + /// + /// A strongly-typed resource class, for looking up localized strings, etc. + /// + // This class was auto-generated by the StronglyTypedResourceBuilder + // class via a tool like ResGen or Visual Studio. + // To add or remove a member, edit your .ResX file then rerun ResGen + // with the /str option, or rebuild your VS project. + [global::System.CodeDom.Compiler.GeneratedCodeAttribute("System.Resources.Tools.StronglyTypedResourceBuilder", "4.0.0.0")] + [global::System.Diagnostics.DebuggerNonUserCodeAttribute()] + [global::System.Runtime.CompilerServices.CompilerGeneratedAttribute()] + internal class Resources { + + private static global::System.Resources.ResourceManager resourceMan; + + private static global::System.Globalization.CultureInfo resourceCulture; + + [global::System.Diagnostics.CodeAnalysis.SuppressMessageAttribute("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")] + internal Resources() { + } + + /// + /// Returns the cached ResourceManager instance used by this class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Resources.ResourceManager ResourceManager { + get { + if (object.ReferenceEquals(resourceMan, null)) { + global::System.Resources.ResourceManager temp = new global::System.Resources.ResourceManager("Ringtoets.StabilityPointStructures.Service.Properties.Resources", typeof(Resources).Assembly); + resourceMan = temp; + } + return resourceMan; + } + } + + /// + /// Overrides the current thread's CurrentUICulture property for all + /// resource lookups using this strongly typed resource class. + /// + [global::System.ComponentModel.EditorBrowsableAttribute(global::System.ComponentModel.EditorBrowsableState.Advanced)] + internal static global::System.Globalization.CultureInfo Culture { + get { + return resourceCulture; + } + set { + resourceCulture = value; + } + } + + /// + /// Looks up a localized string similar to Puntconstructies kunstwerk berekeningsverslag. Klik op details voor meer informatie. + ///{0}. + /// + internal static string StabilityPointStructuresCalculationService_Calculate_Calculation_report_Click_details_for_full_report_0 { + get { + return ResourceManager.GetString("StabilityPointStructuresCalculationService_Calculate_Calculation_report_Click_det" + + "ails_for_full_report_0", resourceCulture); + } + } + + /// + /// Looks up a localized string similar to De berekening voor kunstwerk puntconstructies '{0}' is niet gelukt.. + /// + internal static string StabilityPointStructuresCalculationService_Calculate_Error_in_stabilityPoint_structures_0_calculation { + get { + return ResourceManager.GetString("StabilityPointStructuresCalculationService_Calculate_Error_in_stabilityPoint_stru" + + "ctures_0_calculation", resourceCulture); + } + } + } +} Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/Properties/Resources.resx =================================================================== diff -u --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/Properties/Resources.resx (revision 0) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/Properties/Resources.resx (revision 276a32161f29fcba4af79cf7c7f0aeb254d4db54) @@ -0,0 +1,127 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + text/microsoft-resx + + + 2.0 + + + System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 + + + Puntconstructies kunstwerk berekeningsverslag. Klik op details voor meer informatie. +{0} + + + De berekening voor kunstwerk puntconstructies '{0}' is niet gelukt. + + \ No newline at end of file Index: Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/Ringtoets.StabilityPointStructures.Service.csproj =================================================================== diff -u -rd79d26d2ad423b4287d5cdaeb0ac267089a54bf9 -r276a32161f29fcba4af79cf7c7f0aeb254d4db54 --- Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/Ringtoets.StabilityPointStructures.Service.csproj (.../Ringtoets.StabilityPointStructures.Service.csproj) (revision d79d26d2ad423b4287d5cdaeb0ac267089a54bf9) +++ Ringtoets/StabilityPointStructures/src/Ringtoets.StabilityPointStructures.Service/Ringtoets.StabilityPointStructures.Service.csproj (.../Ringtoets.StabilityPointStructures.Service.csproj) (revision 276a32161f29fcba4af79cf7c7f0aeb254d4db54) @@ -32,6 +32,10 @@ AllRules.ruleset + + ..\..\..\..\packages\log4net.2.0.4\lib\net40-full\log4net.dll + True + @@ -40,12 +44,18 @@ Properties\GlobalAssembly.cs + + True + True + Resources.resx + Copying.licenseheader + @@ -63,6 +73,16 @@ Ringtoets.Common.Service False + + {6A074D65-A81C-4C1C-8E24-F36C916E4ED7} + Ringtoets.Common.Utils + False + + + {888d4097-8bc2-4703-9fb1-8744c94d525e} + Ringtoets.HydraRing.Calculation + False + {70f8cc9c-5bc8-4fb2-b201-eae7fa8088c2} Ringtoets.HydraRing.Data @@ -79,6 +99,12 @@ False + + + ResXFileCodeGenerator + Resources.Designer.cs + + + + + + \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil.Test/Ringtoets.StabilityPointStructures.Data.TestUtil.Test.csproj =================================================================== diff -u -rd79d26d2ad423b4287d5cdaeb0ac267089a54bf9 -r276a32161f29fcba4af79cf7c7f0aeb254d4db54 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil.Test/Ringtoets.StabilityPointStructures.Data.TestUtil.Test.csproj (.../Ringtoets.StabilityPointStructures.Data.TestUtil.Test.csproj) (revision d79d26d2ad423b4287d5cdaeb0ac267089a54bf9) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil.Test/Ringtoets.StabilityPointStructures.Data.TestUtil.Test.csproj (.../Ringtoets.StabilityPointStructures.Data.TestUtil.Test.csproj) (revision 276a32161f29fcba4af79cf7c7f0aeb254d4db54) @@ -49,7 +49,7 @@ Properties\GlobalAssembly.cs - + Fisheye: Tag 276a32161f29fcba4af79cf7c7f0aeb254d4db54 refers to a dead (removed) revision in file `Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil.Test/TestStabilityPointStructureCalculationTest.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil.Test/TestStabilityPointStructuresCalculationTest.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil.Test/TestStabilityPointStructuresCalculationTest.cs (revision 0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil.Test/TestStabilityPointStructuresCalculationTest.cs (revision 276a32161f29fcba4af79cf7c7f0aeb254d4db54) @@ -0,0 +1,81 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets 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 NUnit.Framework; +using Ringtoets.Common.Data.Structures; +using Ringtoets.Common.Data.TestUtil; + +namespace Ringtoets.StabilityPointStructures.Data.TestUtil.Test +{ + [TestFixture] + public class TestStabilityPointStructuresCalculationTest + { + [Test] + public void Constructor_DefaultPropertyValuesAreSet() + { + // Setup + var referenceStructure = new TestStabilityPointStructure(); + + // Call + var calculation = new TestStabilityPointStructuresCalculation(); + + // Assert + Assert.IsInstanceOf>(calculation); + Assert.AreEqual("Nieuwe berekening", calculation.Name); + Assert.IsNotNull(calculation.InputParameters); + Assert.IsNull(calculation.Comments); + Assert.IsFalse(calculation.HasOutput); + + Assert.IsNotNull(calculation.InputParameters.Structure); + Assert.IsNotNull(calculation.InputParameters.HydraulicBoundaryLocation); + + DistributionAssert.AreEqual(referenceStructure.StorageStructureArea, calculation.InputParameters.StorageStructureArea); + DistributionAssert.AreEqual(referenceStructure.AllowedLevelIncreaseStorage, calculation.InputParameters.AllowedLevelIncreaseStorage); + Assert.IsNaN(calculation.InputParameters.StructureNormalOrientation); + DistributionAssert.AreEqual(referenceStructure.WidthFlowApertures, calculation.InputParameters.WidthFlowApertures); + DistributionAssert.AreEqual(referenceStructure.InsideWaterLevel, calculation.InputParameters.InsideWaterLevel); + DistributionAssert.AreEqual(referenceStructure.ThresholdHeightOpenWeir, calculation.InputParameters.ThresholdHeightOpenWeir); + DistributionAssert.AreEqual(referenceStructure.AreaFlowApertures, calculation.InputParameters.AreaFlowApertures); + DistributionAssert.AreEqual(referenceStructure.CriticalOvertoppingDischarge, calculation.InputParameters.CriticalOvertoppingDischarge); + DistributionAssert.AreEqual(referenceStructure.FlowWidthAtBottomProtection, calculation.InputParameters.FlowWidthAtBottomProtection); + Assert.AreEqual(referenceStructure.InflowModelType, calculation.InputParameters.InflowModelType); + DistributionAssert.AreEqual(referenceStructure.ConstructiveStrengthLinearLoadModel, calculation.InputParameters.ConstructiveStrengthLinearLoadModel); + DistributionAssert.AreEqual(referenceStructure.ConstructiveStrengthQuadraticLoadModel, calculation.InputParameters.ConstructiveStrengthQuadraticLoadModel); + DistributionAssert.AreEqual(referenceStructure.BankWidth, calculation.InputParameters.BankWidth); + DistributionAssert.AreEqual(referenceStructure.InsideWaterLevelFailureConstruction, calculation.InputParameters.InsideWaterLevelFailureConstruction); + Assert.AreEqual(referenceStructure.EvaluationLevel, calculation.InputParameters.EvaluationLevel); + DistributionAssert.AreEqual(referenceStructure.LevelCrestStructure, calculation.InputParameters.LevelCrestStructure); + Assert.AreEqual(referenceStructure.VerticalDistance, calculation.InputParameters.VerticalDistance); + Assert.AreEqual(referenceStructure.FailureProbabilityRepairClosure, calculation.InputParameters.FailureProbabilityRepairClosure); + DistributionAssert.AreEqual(referenceStructure.FailureCollisionEnergy, calculation.InputParameters.FailureCollisionEnergy); + DistributionAssert.AreEqual(referenceStructure.ShipMass, calculation.InputParameters.ShipMass); + DistributionAssert.AreEqual(referenceStructure.ShipVelocity, calculation.InputParameters.ShipVelocity); + Assert.AreEqual(referenceStructure.LevellingCount, calculation.InputParameters.LevellingCount); + Assert.AreEqual(referenceStructure.ProbabilityCollisionSecondaryStructure, calculation.InputParameters.ProbabilityCollisionSecondaryStructure); + DistributionAssert.AreEqual(referenceStructure.FlowVelocityStructureClosable, calculation.InputParameters.FlowVelocityStructureClosable); + DistributionAssert.AreEqual(referenceStructure.StabilityLinearLoadModel, calculation.InputParameters.StabilityLinearLoadModel); + DistributionAssert.AreEqual(referenceStructure.StabilityQuadraticLoadModel, calculation.InputParameters.StabilityQuadraticLoadModel); + Assert.AreEqual(referenceStructure.InflowModelType, calculation.InputParameters.InflowModelType); + Assert.AreEqual(1.00, calculation.InputParameters.FactorStormDurationOpenStructure, calculation.InputParameters.FactorStormDurationOpenStructure.GetAccuracy()); + Assert.AreEqual(1.0, calculation.InputParameters.FailureProbabilityStructureWithErosion); + } + } +} \ No newline at end of file Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/Ringtoets.StabilityPointStructures.Data.TestUtil.csproj =================================================================== diff -u -rd79d26d2ad423b4287d5cdaeb0ac267089a54bf9 -r276a32161f29fcba4af79cf7c7f0aeb254d4db54 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/Ringtoets.StabilityPointStructures.Data.TestUtil.csproj (.../Ringtoets.StabilityPointStructures.Data.TestUtil.csproj) (revision d79d26d2ad423b4287d5cdaeb0ac267089a54bf9) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/Ringtoets.StabilityPointStructures.Data.TestUtil.csproj (.../Ringtoets.StabilityPointStructures.Data.TestUtil.csproj) (revision 276a32161f29fcba4af79cf7c7f0aeb254d4db54) @@ -46,7 +46,7 @@ - + Fisheye: Tag 276a32161f29fcba4af79cf7c7f0aeb254d4db54 refers to a dead (removed) revision in file `Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/TestStabilityPointStructureCalculation.cs'. Fisheye: No comparison available. Pass `N' to diff? Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/TestStabilityPointStructuresCalculation.cs =================================================================== diff -u --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/TestStabilityPointStructuresCalculation.cs (revision 0) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Data.TestUtil/TestStabilityPointStructuresCalculation.cs (revision 276a32161f29fcba4af79cf7c7f0aeb254d4db54) @@ -0,0 +1,38 @@ +// Copyright (C) Stichting Deltares 2016. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets 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 Core.Common.Base.Data; +using Ringtoets.Common.Data.Structures; +using Ringtoets.HydraRing.Data; + +namespace Ringtoets.StabilityPointStructures.Data.TestUtil +{ + public class TestStabilityPointStructuresCalculation : StructuresCalculation + { + public TestStabilityPointStructuresCalculation() + { + InputParameters.Structure = new TestStabilityPointStructure(); + InputParameters.HydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "location", 1, 1); + InputParameters.FactorStormDurationOpenStructure = (RoundedDouble)1; + InputParameters.FailureProbabilityStructureWithErosion = 1; + } + } +} Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Service.Test/Ringtoets.StabilityPointStructures.Service.Test.csproj =================================================================== diff -u -rfd68555c649dc41c902960bd0083ba5814255440 -r276a32161f29fcba4af79cf7c7f0aeb254d4db54 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Service.Test/Ringtoets.StabilityPointStructures.Service.Test.csproj (.../Ringtoets.StabilityPointStructures.Service.Test.csproj) (revision fd68555c649dc41c902960bd0083ba5814255440) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Service.Test/Ringtoets.StabilityPointStructures.Service.Test.csproj (.../Ringtoets.StabilityPointStructures.Service.Test.csproj) (revision 276a32161f29fcba4af79cf7c7f0aeb254d4db54) @@ -82,10 +82,18 @@ {4843D6E5-066F-4795-94F5-1D53932DD03C} Ringtoets.Common.Data.TestUtil + + {888D4097-8BC2-4703-9FB1-8744C94D525E} + Ringtoets.HydraRing.Calculation + {70f8cc9c-5bc8-4fb2-b201-eae7fa8088c2} Ringtoets.HydraRing.Data + + {74CBA865-9338-447F-BAD9-28312446AE84} + Ringtoets.HydraRing.Calculation.TestUtil + {3D4B9740-8348-4434-8D77-B611FC6EE57F} Ringtoets.StabilityPointStructures.Data Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Service.Test/StabilityPointStructuresCalculationServiceTest.cs =================================================================== diff -u -rd79d26d2ad423b4287d5cdaeb0ac267089a54bf9 -r276a32161f29fcba4af79cf7c7f0aeb254d4db54 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Service.Test/StabilityPointStructuresCalculationServiceTest.cs (.../StabilityPointStructuresCalculationServiceTest.cs) (revision d79d26d2ad423b4287d5cdaeb0ac267089a54bf9) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Service.Test/StabilityPointStructuresCalculationServiceTest.cs (.../StabilityPointStructuresCalculationServiceTest.cs) (revision 276a32161f29fcba4af79cf7c7f0aeb254d4db54) @@ -20,13 +20,23 @@ // All rights reserved. using System; +using System.ComponentModel; using System.IO; using System.Linq; +using Core.Common.Base.Geometry; using Core.Common.TestUtil; using NUnit.Framework; using Rhino.Mocks; +using Ringtoets.Common.Data.AssessmentSection; +using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Data.TestUtil; +using Ringtoets.HydraRing.Calculation.Calculator.Factory; +using Ringtoets.HydraRing.Calculation.Data; +using Ringtoets.HydraRing.Calculation.Data.Input.Structures; +using Ringtoets.HydraRing.Calculation.TestUtil; +using Ringtoets.HydraRing.Calculation.TestUtil.Calculator; using Ringtoets.HydraRing.Data; using Ringtoets.StabilityPointStructures.Data; using Ringtoets.StabilityPointStructures.Data.TestUtil; @@ -37,6 +47,7 @@ public class StabilityPointStructuresCalculationServiceTest { private static readonly string testDataPath = TestHelper.GetTestDataPath(TestDataPath.Ringtoets.Integration.Service, "HydraRingCalculation"); + private static readonly string validDataFilepath = Path.Combine(testDataPath, "HRD dutch coast south.sqlite"); [Test] public void Validate_ValidCalculationInvalidHydraulicBoundaryDatabase_ReturnsFalse() @@ -90,7 +101,7 @@ const string name = ""; - var calculation = new TestStabilityPointStructureCalculation() + var calculation = new TestStabilityPointStructuresCalculation() { Name = name, InputParameters = @@ -117,5 +128,234 @@ mockRepository.VerifyAll(); } + + [Test] + public void Calculate_InvalidInFlowModelType_ThrowsNotSupportedException() + { + // Setup + var stabilityPointStructuresFailureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mockRepository = new MockRepository(); + var assessmentSectionStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + stabilityPointStructuresFailureMechanism.AddSection(new FailureMechanismSection("test section", new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + })); + + var calculation = new TestStabilityPointStructuresCalculation() + { + InputParameters = + { + InflowModelType = (StabilityPointStructureInflowModelType) 100 + } + }; + + var service = new StabilityPointStructuresCalculationService(); + + // Call + using (new HydraRingCalculatorFactoryConfig()) + { + var calculator = ((TestHydraRingCalculatorFactory) HydraRingCalculatorFactory.Instance).StructuresClosureCalculator; + + // Call + TestDelegate call = () => service.Calculate(calculation, + assessmentSectionStub, + stabilityPointStructuresFailureMechanism, + testDataPath); + + StructuresClosureCalculationInput[] calculationInputs = calculator.ReceivedInputs.ToArray(); + + // Assert + Assert.AreEqual(0, calculationInputs.Length); + var exception = Assert.Throws(call); + Assert.AreEqual("calculation", exception.ParamName); + StringAssert.StartsWith("The value of argument 'calculation' (100) is invalid for Enum type 'StabilityPointStructureInflowModelType'.", exception.Message); + } + mockRepository.VerifyAll(); + } + + [Test] + public void Calculate_InvalidLoadSchematizationType_ThrowsNotSupportedException() + { + // Setup + var stabilityPointStructuresFailureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mockRepository = new MockRepository(); + var assessmentSectionStub = mockRepository.Stub(); + mockRepository.ReplayAll(); + + stabilityPointStructuresFailureMechanism.AddSection(new FailureMechanismSection("test section", new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + })); + + var calculation = new TestStabilityPointStructuresCalculation() + { + InputParameters = + { + LoadSchematizationType = (LoadSchematizationType) 100 + } + }; + + var service = new StabilityPointStructuresCalculationService(); + + // Call + using (new HydraRingCalculatorFactoryConfig()) + { + var calculator = ((TestHydraRingCalculatorFactory) HydraRingCalculatorFactory.Instance).StructuresClosureCalculator; + + // Call + TestDelegate call = () => service.Calculate(calculation, + assessmentSectionStub, + stabilityPointStructuresFailureMechanism, + testDataPath); + + StructuresClosureCalculationInput[] calculationInputs = calculator.ReceivedInputs.ToArray(); + + // Assert + Assert.AreEqual(0, calculationInputs.Length); + var exception = Assert.Throws(call); + Assert.AreEqual("calculation", exception.ParamName); + StringAssert.StartsWith("The value of argument 'calculation' (100) is invalid for Enum type 'LoadSchematizationType'.", exception.Message); + } + mockRepository.VerifyAll(); + } + + [Test] + [TestCase(true, false)] + [TestCase(true, true)] + [TestCase(false, false)] + public void Calculate_VariousLowSillLinearCalculations_InputPropertiesCorrectlySentToCalculator(bool useForeshore, bool useBreakWater) + { + // Setup + var stabilityPointStructuresFailureMechanism = new StabilityPointStructuresFailureMechanism(); + + var mockRepository = new MockRepository(); + var assessmentSectionStub = AssessmentSectionHelper.CreateAssessmentSectionStub(stabilityPointStructuresFailureMechanism, mockRepository); + mockRepository.ReplayAll(); + + stabilityPointStructuresFailureMechanism.AddSection(new FailureMechanismSection("test section", new[] + { + new Point2D(0, 0), + new Point2D(1, 1) + })); + + var calculation = new TestStabilityPointStructuresCalculation() + { + InputParameters = + { + HydraulicBoundaryLocation = assessmentSectionStub.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001), + InflowModelType = StabilityPointStructureInflowModelType.LowSill, + LoadSchematizationType = LoadSchematizationType.Linear + } + }; + + if (useForeshore) + { + calculation.InputParameters.ForeshoreProfile = new ForeshoreProfile(new Point2D(0, 0), + new[] + { + new Point2D(1, 1), + new Point2D(2, 2) + }, + useBreakWater ? new BreakWater(BreakWaterType.Wall, 3.0) : null, + new ForeshoreProfile.ConstructionProperties()); + } + + FailureMechanismSection failureMechanismSection = stabilityPointStructuresFailureMechanism.Sections.First(); + + using (new HydraRingCalculatorFactoryConfig()) + { + var calculator = ((TestHydraRingCalculatorFactory) HydraRingCalculatorFactory.Instance).StructuresStabilityPointCalculator; + + // Call + new StabilityPointStructuresCalculationService().Calculate(calculation, + assessmentSectionStub, + stabilityPointStructuresFailureMechanism, + validDataFilepath); + + // Assert + StructuresStabilityPointCalculationInput[] calculationInputs = calculator.ReceivedInputs.ToArray(); + Assert.AreEqual(1, calculationInputs.Length); + Assert.AreEqual(testDataPath, calculator.HydraulicBoundaryDatabaseDirectory); + Assert.AreEqual(assessmentSectionStub.Id, calculator.RingId); + + GeneralStabilityPointStructuresInput generalInput = stabilityPointStructuresFailureMechanism.GeneralInput; + StabilityPointStructuresInput input = calculation.InputParameters; + var expectedInput = new StructuresStabilityPointLowSillLinearCalculationInput( + 1300001, + new HydraRingSection(1, failureMechanismSection.GetSectionLength(), input.StructureNormalOrientation), + useForeshore ? input.ForeshoreGeometry.Select(c => new HydraRingForelandPoint(c.X, c.Y)) : new HydraRingForelandPoint[0], + useBreakWater ? new HydraRingBreakWater((int) input.BreakWater.Type, input.BreakWater.Height) : null, + input.VolumicWeightWater, + generalInput.GravitationalAcceleration, + input.LevelCrestStructure.Mean, + input.LevelCrestStructure.StandardDeviation, + input.StructureNormalOrientation, + input.FactorStormDurationOpenStructure, + input.ModelFactorSuperCriticalFlow.Mean, + input.ModelFactorSuperCriticalFlow.StandardDeviation, + input.ThresholdHeightOpenWeir.Mean, + input.ThresholdHeightOpenWeir.StandardDeviation, + input.InsideWaterLevelFailureConstruction.Mean, + input.InsideWaterLevelFailureConstruction.StandardDeviation, + input.FailureProbabilityRepairClosure, + input.FailureCollisionEnergy.Mean, + input.FailureCollisionEnergy.CoefficientOfVariation, + generalInput.ModelFactorCollisionLoad.Mean, + generalInput.ModelFactorCollisionLoad.CoefficientOfVariation, + input.ShipMass.Mean, + input.ShipMass.CoefficientOfVariation, + input.ShipVelocity.Mean, + input.ShipVelocity.CoefficientOfVariation, + input.LevellingCount, + input.ProbabilityCollisionSecondaryStructure, + input.FlowVelocityStructureClosable.Mean, + input.FlowVelocityStructureClosable.StandardDeviation, + input.InsideWaterLevel.Mean, + input.InsideWaterLevel.StandardDeviation, + input.AllowedLevelIncreaseStorage.Mean, + input.AllowedLevelIncreaseStorage.StandardDeviation, + generalInput.ModelFactorStorageVolume.Mean, + generalInput.ModelFactorStorageVolume.StandardDeviation, + input.StorageStructureArea.Mean, + input.StorageStructureArea.CoefficientOfVariation, + generalInput.ModelFactorInflowVolume, + input.FlowWidthAtBottomProtection.Mean, + input.FlowWidthAtBottomProtection.StandardDeviation, + input.CriticalOvertoppingDischarge.Mean, + input.CriticalOvertoppingDischarge.CoefficientOfVariation, + input.FailureProbabilityStructureWithErosion, + input.StormDuration.Mean, + input.StormDuration.CoefficientOfVariation, + input.BankWidth.Mean, + input.BankWidth.StandardDeviation, + input.EvaluationLevel, + generalInput.ModelFactorLoadEffect.Mean, + generalInput.ModelFactorLoadEffect.StandardDeviation, + generalInput.WaveRatioMaxHN, + generalInput.WaveRatioMaxHStandardDeviation, + input.VerticalDistance, + generalInput.ModificationFactorWavesSlowlyVaryingPressureComponent, + generalInput.ModificationFactorDynamicOrImpulsivePressureComponent, + input.ModelFactorSuperCriticalFlow.Mean, + input.ModelFactorSuperCriticalFlow.StandardDeviation, + input.ConstructiveStrengthLinearLoadModel.Mean, + input.ConstructiveStrengthLinearLoadModel.CoefficientOfVariation, + input.StabilityLinearLoadModel.Mean, + input.StabilityLinearLoadModel.CoefficientOfVariation, + input.WidthFlowApertures.Mean, + input.WidthFlowApertures.CoefficientOfVariation); + + StructuresStabilityPointLowSillLinearCalculationInput actualInput = (StructuresStabilityPointLowSillLinearCalculationInput)calculationInputs[0]; + HydraRingDataEqualityHelper.AreEqual(expectedInput, actualInput); + Assert.IsFalse(calculator.IsCanceled); + } + mockRepository.VerifyAll(); + } } } \ No newline at end of file