Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj =================================================================== diff -u -r056c24804fa3267952bebae1f58705bf45338b07 -r7082f74ed1f0f3a0601a2d8833c864b8c08bea59 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 056c24804fa3267952bebae1f58705bf45338b07) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Application.Ringtoets.Storage.Test.csproj (.../Application.Ringtoets.Storage.Test.csproj) (revision 7082f74ed1f0f3a0601a2d8833c864b8c08bea59) @@ -77,12 +77,11 @@ Properties\GlobalAssembly.cs - + - - + @@ -98,6 +97,7 @@ + @@ -127,6 +127,8 @@ + + @@ -154,6 +156,7 @@ + @@ -166,7 +169,7 @@ - + Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StabilityStoneCover/StabilityStoneCoverWaveConditionsCalculationCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StabilityStoneCover/StabilityStoneCoverWaveConditionsCalculationCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StabilityStoneCover/StabilityStoneCoverWaveConditionsCalculationCreateExtensionsTest.cs (revision 7082f74ed1f0f3a0601a2d8833c864b8c08bea59) @@ -0,0 +1,230 @@ +// 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 System; +using System.Collections.Generic; +using System.Linq; +using Application.Ringtoets.Storage.Create; +using Application.Ringtoets.Storage.Create.StabilityStoneCover; +using Application.Ringtoets.Storage.DbContext; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using NUnit.Framework; +using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.HydraRing.Data; +using Ringtoets.Revetment.Data; +using Ringtoets.StabilityStoneCover.Data; + +namespace Application.Ringtoets.Storage.Test.Create.StabilityStoneCover +{ + [TestFixture] + public class StabilityStoneCoverWaveConditionsCalculationCreateExtensionsTest + { + private static IEnumerable ValidWaveConditionsInputs + { + get + { + yield return new TestCaseData(1.0, true, 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.Half); + yield return new TestCaseData(1.0, true, 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.One); + yield return new TestCaseData(1.0, true, 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.Two); + + yield return new TestCaseData(1.0, false, 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.Half); + yield return new TestCaseData(1.0, false, 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.One); + yield return new TestCaseData(1.0, false, 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.Two); + + yield return new TestCaseData(double.NaN, true, double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.Half); + yield return new TestCaseData(double.NaN, true, double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.One); + yield return new TestCaseData(double.NaN, true, double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.Two); + + yield return new TestCaseData(double.NaN, false, double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.Half); + yield return new TestCaseData(double.NaN, false, double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.One); + yield return new TestCaseData(double.NaN, false, double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.Two); + } + } + + [Test] + public void Create_PersistenceRegistryIsNull_ThrowArgumentNullException() + { + // Setup + var calculation = new StabilityStoneCoverWaveConditionsCalculation(); + + // Call + TestDelegate call = () => calculation.Create(null, 0); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual(paramName, "registry"); + } + + [Test] + [TestCaseSource("ValidWaveConditionsInputs")] + public void Create_StabilityStoneCoverWaveConditionsCalculationWithPropertiesSet_ReturnStabilityStoneCoverWaveConditionsCalculationEntity( + double orientation, bool useBreakWater, double lowerBoundaryRevetment, + double upperBoundaryRevetment, double lowerBoundaryWaterLevels, + double upperBoundaryWaterLevels, WaveConditionsInputStepSize stepSize) + { + // Setup + const string name = "Name"; + const string comments = "comments"; + const int order = 1234; + + var calculation = new StabilityStoneCoverWaveConditionsCalculation + { + Name = name, + Comments = comments, + InputParameters = + { + Orientation = (RoundedDouble) orientation, + UseBreakWater = useBreakWater, + UpperBoundaryRevetment = (RoundedDouble) upperBoundaryRevetment, + LowerBoundaryRevetment = (RoundedDouble) lowerBoundaryRevetment, + UpperBoundaryWaterLevels = (RoundedDouble) upperBoundaryWaterLevels, + LowerBoundaryWaterLevels = (RoundedDouble) lowerBoundaryWaterLevels, + StepSize = stepSize + } + }; + + var registry = new PersistenceRegistry(); + + // Call + StabilityStoneCoverWaveConditionsCalculationEntity entity = calculation.Create(registry, order); + + // Assert + Assert.AreEqual(name, entity.Name); + Assert.AreEqual(comments, entity.Comments); + + WaveConditionsInput input = calculation.InputParameters; + Assert.AreEqual(input.Orientation.Value, entity.Orientation); + Assert.AreEqual(Convert.ToByte(useBreakWater), entity.UseBreakWater); + Assert.AreEqual(Convert.ToByte(false), entity.UseForeshore); + Assert.AreEqual(input.UpperBoundaryRevetment, entity.UpperBoundaryRevetment, input.UpperBoundaryRevetment.GetAccuracy()); + Assert.AreEqual(input.LowerBoundaryRevetment, entity.LowerBoundaryRevetment, input.LowerBoundaryRevetment.GetAccuracy()); + Assert.AreEqual(input.UpperBoundaryWaterLevels, entity.UpperBoundaryWaterLevels, input.UpperBoundaryWaterLevels.GetAccuracy()); + Assert.AreEqual(input.LowerBoundaryWaterLevels, entity.LowerBoundaryWaterLevels, input.LowerBoundaryWaterLevels.GetAccuracy()); + Assert.AreEqual(Convert.ToByte(input.StepSize), entity.StepSize); + + Assert.AreEqual(order, entity.Order); + Assert.AreEqual(0, entity.StabilityStoneCoverWaveConditionsCalculationEntityId); + Assert.IsNull(entity.CalculationGroupEntity); + Assert.AreEqual(0, entity.StabilityStoneCoverWaveConditionsOutputEntities.Count); + Assert.IsNull(entity.ForeshoreProfileEntityId); + Assert.IsNull(entity.HydraulicLocationEntityId); + } + + [Test] + public void Create_StringPropertiesDoNotShareReference() + { + // Setup + const string name = "A"; + const string comments = "B"; + var calculation = new StabilityStoneCoverWaveConditionsCalculation() + { + Name = name, + Comments = comments + }; + + var registry = new PersistenceRegistry(); + + // Call + StabilityStoneCoverWaveConditionsCalculationEntity entity = calculation.Create(registry, 0); + + // Assert + Assert.AreNotSame(name, entity.Name, + "To create stable binary representations/fingerprints, it's really important that strings are not shared."); + Assert.AreEqual(name, entity.Name); + + Assert.AreNotSame(comments, entity.Comments, + "To create stable binary representations/fingerprints, it's really important that strings are not shared."); + Assert.AreEqual(comments, entity.Comments); + } + + [Test] + public void Create_HydraulicBoundaryLocation_EntityHasHydraulicLocationEntity() + { + // Setup + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "A", 2.3, 4.5); + + var registry = new PersistenceRegistry(); + HydraulicLocationEntity hydraulicLocationEntity = hydraulicBoundaryLocation.Create(registry, 0); + + var calculation = new StabilityStoneCoverWaveConditionsCalculation + { + InputParameters = + { + HydraulicBoundaryLocation = hydraulicBoundaryLocation + } + }; + + // Call + StabilityStoneCoverWaveConditionsCalculationEntity entity = calculation.Create(registry, 0); + + // Assert + Assert.AreSame(hydraulicLocationEntity, entity.HydraulicLocationEntity); + } + + [Test] + public void Create_HasForeshoreProfile_EntityHasForeshoreProfileEntity() + { + // Setup + var registry = new PersistenceRegistry(); + var calculation = new StabilityStoneCoverWaveConditionsCalculation + { + InputParameters = + { + ForeshoreProfile = new ForeshoreProfile(new Point2D(1, 2), + Enumerable.Empty(), + new BreakWater(BreakWaterType.Caisson, 2), + new ForeshoreProfile.ConstructionProperties()) + } + }; + + // Call + StabilityStoneCoverWaveConditionsCalculationEntity entity = calculation.Create(registry, 0); + + // Assert + Assert.IsNotNull(entity.ForeshoreProfileEntity); + } + + [Test] + public void Create_HasCalculationOutput_EntityHasCalculationOutputEntity() + { + // Setup + var registry = new PersistenceRegistry(); + var calculation = new StabilityStoneCoverWaveConditionsCalculation + { + Output = new StabilityStoneCoverWaveConditionsOutput(new[] + { + new WaveConditionsOutput(1, 2, 3, 4) + }, new[] + { + new WaveConditionsOutput(1, 2, 3, 4) + }) + }; + + // Call + StabilityStoneCoverWaveConditionsCalculationEntity entity = calculation.Create(registry, 0); + + // Assert + Assert.AreEqual(2, entity.StabilityStoneCoverWaveConditionsOutputEntities.Count); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StabilityStoneCover/StabilityStoneCoverWaveConditionsOutputCreateExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StabilityStoneCover/StabilityStoneCoverWaveConditionsOutputCreateExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StabilityStoneCover/StabilityStoneCoverWaveConditionsOutputCreateExtensionsTest.cs (revision 7082f74ed1f0f3a0601a2d8833c864b8c08bea59) @@ -0,0 +1,97 @@ +// 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 System; +using Application.Ringtoets.Storage.Create; +using Application.Ringtoets.Storage.Create.StabilityStoneCover; +using Application.Ringtoets.Storage.DbContext; +using NUnit.Framework; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Revetment.Data; + +namespace Application.Ringtoets.Storage.Test.Create.StabilityStoneCover +{ + [TestFixture] + public class StabilityStoneCoverWaveConditionsOutputCreateExtensionsTest + { + [Test] + public void Create_PersistenceRegistryIsNull_ThrowArgumentNullException() + { + // Setup + var output = new WaveConditionsOutput(1.1, 2.2, 3.3, 4.4); + + // Call + TestDelegate call = () => output.CreateStabilityStoneCoverWaveConditionsOutput(WaveConditionsOutputType.Columns, null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("registry", paramName); + } + + [Test] + [TestCase(WaveConditionsOutputType.Blocks)] + [TestCase(WaveConditionsOutputType.Columns)] + public void Create_AllOutputValuesSet_ReturnEntity(WaveConditionsOutputType outputType) + { + // Setup + var output = new WaveConditionsOutput(1.1, 2.2, 3.3, 4.4); + + var registry = new PersistenceRegistry(); + + // Call + StabilityStoneCoverWaveConditionsOutputEntity entity = output.CreateStabilityStoneCoverWaveConditionsOutput(outputType, registry); + + // Assert + Assert.AreEqual(output.WaterLevel, entity.WaterLevel, output.WaterLevel.GetAccuracy()); + Assert.AreEqual(output.WaveHeight, entity.WaveHeight, output.WaveHeight.GetAccuracy()); + Assert.AreEqual(output.WavePeakPeriod, entity.WavePeakPeriod, output.WavePeakPeriod.GetAccuracy()); + Assert.AreEqual(output.WaveAngle, entity.WaveAngle, output.WaveAngle.GetAccuracy()); + Assert.AreEqual(Convert.ToByte(outputType), entity.OutputType); + + Assert.AreEqual(0, entity.StabilityStoneCoverWaveConditionsOutputEntityId); + Assert.AreEqual(0, entity.StabilityStoneCoverWaveConditionsCalculationEntityId); + } + + [Test] + [TestCase(WaveConditionsOutputType.Blocks)] + [TestCase(WaveConditionsOutputType.Columns)] + public void Create_AllOutputValuesNaN_ReturnEntityWithNullValues(WaveConditionsOutputType outputType) + { + // Setup + var output = new WaveConditionsOutput(double.NaN, double.NaN, double.NaN, double.NaN); + + var registry = new PersistenceRegistry(); + + // Call + StabilityStoneCoverWaveConditionsOutputEntity entity = output.CreateStabilityStoneCoverWaveConditionsOutput(outputType, registry); + + // Assert + Assert.IsNull(entity.WaterLevel); + Assert.IsNull(entity.WaveHeight); + Assert.IsNull(entity.WavePeakPeriod); + Assert.IsNull(entity.WaveAngle); + Assert.AreEqual(Convert.ToByte(outputType), entity.OutputType); + + Assert.AreEqual(0, entity.StabilityStoneCoverWaveConditionsOutputEntityId); + Assert.AreEqual(0, entity.StabilityStoneCoverWaveConditionsCalculationEntityId); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StabilityStoneCover/StabilityStoneCoverSectionResultEntityReadExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StabilityStoneCover/StabilityStoneCoverSectionResultEntityReadExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StabilityStoneCover/StabilityStoneCoverSectionResultEntityReadExtensionsTest.cs (revision 7082f74ed1f0f3a0601a2d8833c864b8c08bea59) @@ -0,0 +1,104 @@ +// 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 System; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.Read; +using Application.Ringtoets.Storage.TestUtil; +using NUnit.Framework; +using Ringtoets.Common.Data.FailureMechanism; +using Ringtoets.StabilityStoneCover.Data; + +namespace Application.Ringtoets.Storage.Test.Read.StabilityStoneCover +{ + [TestFixture] + public class StabilityStoneCoverSectionResultEntityReadExtensionsTest + { + [Test] + public void Read_SectionResultIsNull_ThrowArgumentNullException() + { + // Setup + var entity = new StabilityStoneCoverSectionResultEntity(); + + // Call + TestDelegate call = () => entity.Read(null); + + // Assert + string paramName = Assert.Throws(call).ParamName; + Assert.AreEqual("sectionResult", paramName); + } + + [Test] + [TestCase(true, AssessmentLayerTwoAResult.Failed)] + [TestCase(false, AssessmentLayerTwoAResult.Successful)] + [TestCase(false, AssessmentLayerTwoAResult.Failed)] + public void Read_WithDecimalParameterValues_ReturnStabilityStoneCoverSectionResultWithDoubleParameterValues(bool layerOne, AssessmentLayerTwoAResult layerTwoA) + { + // Setup + var random = new Random(21); + double layerThree = random.NextDouble(); + var collector = new ReadConversionCollector(); + + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new StabilityStoneCoverSectionResultEntity + { + LayerThree = layerThree, + LayerTwoA = Convert.ToByte(layerTwoA), + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + var sectionResult = new StabilityStoneCoverFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult); + + // Assert + Assert.IsNotNull(sectionResult); + Assert.AreEqual(layerTwoA, sectionResult.AssessmentLayerTwoA); + Assert.AreEqual(layerThree, sectionResult.AssessmentLayerThree, 1e-6); + } + + [Test] + [TestCase(true, AssessmentLayerTwoAResult.Failed)] + [TestCase(false, AssessmentLayerTwoAResult.Successful)] + [TestCase(false, AssessmentLayerTwoAResult.Failed)] + public void Read_WithNullLayerThree_ReturnStabilityStoneCoverSectionResultWithNullParameters(bool layerOne, AssessmentLayerTwoAResult layerTwoA) + { + // Setup + var collector = new ReadConversionCollector(); + var failureMechanismSectionEntity = new FailureMechanismSectionEntity(); + collector.Read(failureMechanismSectionEntity, new TestFailureMechanismSection()); + var entity = new StabilityStoneCoverSectionResultEntity + { + LayerTwoA = Convert.ToByte(layerTwoA), + LayerThree = null, + FailureMechanismSectionEntity = failureMechanismSectionEntity + }; + var sectionResult = new StabilityStoneCoverFailureMechanismSectionResult(new TestFailureMechanismSection()); + + // Call + entity.Read(sectionResult); + + // Assert + Assert.IsNaN(sectionResult.AssessmentLayerThree); + } + } +} \ No newline at end of file Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StabilityStoneCover/StabilityStoneCoverWaveConditionsCalculationEntityReadExtensionsTest.cs =================================================================== diff -u -reec9f1ac3701c6155c49101fcc9649d51ffdc319 -r7082f74ed1f0f3a0601a2d8833c864b8c08bea59 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StabilityStoneCover/StabilityStoneCoverWaveConditionsCalculationEntityReadExtensionsTest.cs (.../StabilityStoneCoverWaveConditionsCalculationEntityReadExtensionsTest.cs) (revision eec9f1ac3701c6155c49101fcc9649d51ffdc319) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StabilityStoneCover/StabilityStoneCoverWaveConditionsCalculationEntityReadExtensionsTest.cs (.../StabilityStoneCoverWaveConditionsCalculationEntityReadExtensionsTest.cs) (revision 7082f74ed1f0f3a0601a2d8833c864b8c08bea59) @@ -20,10 +20,10 @@ // All rights reserved. using System; +using System.Collections.Generic; using System.Linq; using Application.Ringtoets.Storage.DbContext; using Application.Ringtoets.Storage.Read; -using Application.Ringtoets.Storage.Read.Piping; using Application.Ringtoets.Storage.Read.StabilityStoneCover; using Application.Ringtoets.Storage.Serializers; using Application.Ringtoets.Storage.TestUtil; @@ -33,8 +33,6 @@ using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.TestUtil; using Ringtoets.HydraRing.Data; -using Ringtoets.Piping.Data; -using Ringtoets.Piping.Primitives; using Ringtoets.Revetment.Data; using Ringtoets.StabilityStoneCover.Data; @@ -43,6 +41,61 @@ [TestFixture] public class StabilityStoneCoverWaveConditionsCalculationEntityReadExtensionsTest { + private static IEnumerable ValidWaveConditionsInputs + { + get + { + yield return new TestCaseData("N", "C", 1.0, true, BreakWaterType.Caisson, 2.0, true, + 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.Half); + yield return new TestCaseData("N", "C", 1.0, true, BreakWaterType.Dam, 2.0, true, + 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.One); + yield return new TestCaseData("N", "C", 1.0, true, BreakWaterType.Wall, 2.0, true, + 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.Two); + + yield return new TestCaseData("N", "C", 1.0, true, BreakWaterType.Wall, 2.0, false, + 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.Half); + yield return new TestCaseData("N", "C", 1.0, true, BreakWaterType.Dam, 2.0, false, + 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.One); + yield return new TestCaseData("N", "C", 1.0, true, BreakWaterType.Caisson, 2.0, false, + 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.Two); + + yield return new TestCaseData("N", "C", 1.0, false, BreakWaterType.Caisson, 2.0, true, + 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.Half); + yield return new TestCaseData("N", "C", 1.0, false, BreakWaterType.Caisson, 2.0, true, + 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.One); + yield return new TestCaseData("N", "C", 1.0, false, BreakWaterType.Caisson, 2.0, true, + 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.Two); + + yield return new TestCaseData("N", "C", 1.0, false, BreakWaterType.Caisson, 2.0, false, + 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.Half); + yield return new TestCaseData("N", "C", 1.0, false, BreakWaterType.Caisson, 2.0, false, + 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.One); + yield return new TestCaseData("N", "C", 1.0, false, BreakWaterType.Caisson, 2.0, false, + 3.58, 6.10, 3.40, 5.88, WaveConditionsInputStepSize.Two); + + yield return new TestCaseData(null, null, double.NaN, true, BreakWaterType.Caisson, double.NaN, true, + double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.Half); + yield return new TestCaseData(null, null, double.NaN, true, BreakWaterType.Caisson, double.NaN, true, + double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.One); + yield return new TestCaseData(null, null, double.NaN, true, BreakWaterType.Caisson, double.NaN, true, + double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.Two); + + yield return new TestCaseData(null, null, double.NaN, true, BreakWaterType.Caisson, double.NaN, false, + double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.Half); + yield return new TestCaseData(null, null, double.NaN, true, BreakWaterType.Caisson, double.NaN, false, + double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.One); + yield return new TestCaseData(null, null, double.NaN, true, BreakWaterType.Caisson, double.NaN, false, + double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.Two); + + yield return new TestCaseData(null, null, double.NaN, false, BreakWaterType.Caisson, double.NaN, false, + double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.Half); + yield return new TestCaseData(null, null, double.NaN, false, BreakWaterType.Caisson, double.NaN, false, + double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.One); + yield return new TestCaseData(null, null, double.NaN, false, BreakWaterType.Caisson, double.NaN, false, + double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.Two); + } + } + [Test] public void Read_CollectorIsNull_ThrowArgumentNullException() { @@ -58,11 +111,12 @@ } [Test] - [TestCase("haha", "hihi", true, BreakWaterType.Dam, 0.98, true, 0.0, 3.4, 2.4, 16.8, 2.8, WaveConditionsInputStepSize.Two)] - [TestCase(null, null, false, BreakWaterType.Wall, 0.0, false, double.NaN, double.NaN, double.NaN, double.NaN, double.NaN, WaveConditionsInputStepSize.One)] - public void Read_ValidEntity_ReturnStabilityStoneCoverWaveConditionsCalculation(string name, string comments, bool useBreakWater, BreakWaterType breakWaterType, - double breakWaterHeight, bool useForeshore, double orientation, double upperBoundaryRevetment, double lowerBoundaryRevetment, double upperBoundaryWaterLevels, - double lowerBoundaryWaterLevels, WaveConditionsInputStepSize stepSize) + [TestCaseSource("ValidWaveConditionsInputs")] + public void Read_ValidEntity_ReturnStabilityStoneCoverWaveConditionsCalculation( + string name, string comments, + double orientation, bool useBreakWater, BreakWaterType breakWaterType, double breakWaterHeight, bool useForeshore, double lowerBoundaryRevetment, + double upperBoundaryRevetment, double lowerBoundaryWaterLevels, + double upperBoundaryWaterLevels, WaveConditionsInputStepSize stepSize) { // Setup var entity = new StabilityStoneCoverWaveConditionsCalculationEntity @@ -78,7 +132,7 @@ LowerBoundaryRevetment = lowerBoundaryRevetment, UpperBoundaryWaterLevels = upperBoundaryWaterLevels, LowerBoundaryWaterLevels = lowerBoundaryWaterLevels, - StepSize = (byte)stepSize + StepSize = (byte) stepSize }; var collector = new ReadConversionCollector(); @@ -199,6 +253,27 @@ Assert.IsTrue(collector.Contains(hydraulicLocationEntity)); } + [Test] + public void Read_EntityWithCalculationOutputEntity_CalculationWithOutput() + { + // Setup + var entity = new StabilityStoneCoverWaveConditionsCalculationEntity + { + StabilityStoneCoverWaveConditionsOutputEntities = + { + new StabilityStoneCoverWaveConditionsOutputEntity() + } + }; + + var collector = new ReadConversionCollector(); + + // Call + StabilityStoneCoverWaveConditionsCalculation calculation = entity.Read(collector); + + // Assert + Assert.IsNotNull(calculation.Output); + } + private static void AssertRoundedDouble(double expectedValue, RoundedDouble actualValue) { Assert.AreEqual(expectedValue, actualValue, actualValue.GetAccuracy()); Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StabilityStoneCover/StabilityStoneCoverWaveConditionsOutputEntityReadExtensionsTest.cs =================================================================== diff -u --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StabilityStoneCover/StabilityStoneCoverWaveConditionsOutputEntityReadExtensionsTest.cs (revision 0) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StabilityStoneCover/StabilityStoneCoverWaveConditionsOutputEntityReadExtensionsTest.cs (revision 7082f74ed1f0f3a0601a2d8833c864b8c08bea59) @@ -0,0 +1,86 @@ +// 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 System; +using Application.Ringtoets.Storage.DbContext; +using Application.Ringtoets.Storage.Read.StabilityStoneCover; +using NUnit.Framework; +using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Revetment.Data; + +namespace Application.Ringtoets.Storage.Test.Read.StabilityStoneCover +{ + [TestFixture] + public class StabilityStoneCoverWaveConditionsOutputEntityReadExtensionsTest + { + [Test] + public void Read_ValidEntity_ReturnOutput() + { + // Setup + var random = new Random(12); + var entity = new StabilityStoneCoverWaveConditionsOutputEntity + { + WaterLevel = random.NextDouble(), + WaveHeight = random.NextDouble(), + WavePeakPeriod = random.NextDouble(), + WaveAngle = random.NextDouble() + }; + + // Call + WaveConditionsOutput output = entity.Read(); + + // Assert + Assert.IsNotNull(entity.WaterLevel); + Assert.AreEqual(entity.WaterLevel.Value, output.WaterLevel, output.WaterLevel.GetAccuracy()); + + Assert.IsNotNull(entity.WaveHeight); + Assert.AreEqual(entity.WaveHeight.Value, output.WaveHeight, output.WaveHeight.GetAccuracy()); + + Assert.IsNotNull(entity.WavePeakPeriod); + Assert.AreEqual(entity.WavePeakPeriod.Value, output.WavePeakPeriod, output.WavePeakPeriod.GetAccuracy()); + + Assert.IsNotNull(entity.WaveAngle); + Assert.AreEqual(entity.WaveAngle.Value, output.WaveAngle, output.WaveAngle.GetAccuracy()); + } + + [Test] + public void Read_ValidEntityWithNullParameterValues_ReturnPipingOutput() + { + // Setup + var entity = new StabilityStoneCoverWaveConditionsOutputEntity + { + WaterLevel = null, + WaveHeight = null, + WavePeakPeriod = null, + WaveAngle = null + }; + + // Call + WaveConditionsOutput output = entity.Read(); + + // Assert + Assert.IsNaN(output.WaterLevel); + Assert.IsNaN(output.WaveHeight); + Assert.IsNaN(output.WavePeakPeriod); + Assert.IsNaN(output.WaveAngle); + } + } +} \ No newline at end of file Fisheye: Tag 7082f74ed1f0f3a0601a2d8833c864b8c08bea59 refers to a dead (removed) revision in file `Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Read/StabilityStoneCoverSectionResultEntityReadExtensionsTest.cs'. Fisheye: No comparison available. Pass `N' to diff?