Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Factories/DuneErosionMapDataFeaturesFactoryTest.cs =================================================================== diff -u -r96ac681afe124833d844548e00dee33c5aa81414 -r89931b99566016e46b0f5389b0d92168d303b1c1 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Factories/DuneErosionMapDataFeaturesFactoryTest.cs (.../DuneErosionMapDataFeaturesFactoryTest.cs) (revision 96ac681afe124833d844548e00dee33c5aa81414) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Factories/DuneErosionMapDataFeaturesFactoryTest.cs (.../DuneErosionMapDataFeaturesFactoryTest.cs) (revision 89931b99566016e46b0f5389b0d92168d303b1c1) @@ -28,10 +28,10 @@ using Core.Components.Gis.Features; using NUnit.Framework; using Ringtoets.Common.Data.TestUtil; -using Ringtoets.Common.Util.TestUtil; using Ringtoets.DuneErosion.Data; using Ringtoets.DuneErosion.Data.TestUtil; using Ringtoets.DuneErosion.Forms.Factories; +using Ringtoets.DuneErosion.Forms.TestUtil; namespace Ringtoets.DuneErosion.Forms.Test.Factories { @@ -158,7 +158,7 @@ [Test] [TestCase(true)] [TestCase(false)] - public void CreateDuneLocationsFeatures_WithFailureMechanism_ReturnFeature(bool withOutput) + public void CreateDuneLocationsFeatures_WithFailureMechanism_ReturnFeatures(bool withOutput) { // Setup var duneLocations = new[] @@ -179,69 +179,7 @@ IEnumerable features = DuneErosionMapDataFeaturesFactory.CreateDuneLocationFeatures(failureMechanism); // Assert - Assert.AreEqual(duneLocations.Length, features.Count()); - - for (var i = 0; i < duneLocations.Length; i++) - { - DuneLocation expectedDuneLocation = duneLocations[i]; - MapFeature mapFeature = features.ElementAt(i); - - Assert.AreEqual(expectedDuneLocation.Id, mapFeature.MetaData["ID"]); - Assert.AreEqual(expectedDuneLocation.Name, mapFeature.MetaData["Naam"]); - Assert.AreEqual(expectedDuneLocation.CoastalAreaId, mapFeature.MetaData["Kustvaknummer"]); - Assert.AreEqual(expectedDuneLocation.Offset.ToString("0.#", CultureInfo.InvariantCulture), mapFeature.MetaData["Metrering"]); - Assert.AreEqual(expectedDuneLocation.Location, mapFeature.MapGeometries.First().PointCollections.First().Single()); - - MapFeaturesMetaDataTestHelper.AssertMetaData( - GetExpectedWaterLevel(failureMechanism.CalculationsForMechanismSpecificFactorizedSignalingNorm, expectedDuneLocation), - mapFeature, "Rekenwaarde h(Iv->IIv)"); - MapFeaturesMetaDataTestHelper.AssertMetaData( - GetExpectedWaterLevel(failureMechanism.CalculationsForMechanismSpecificSignalingNorm, expectedDuneLocation), - mapFeature, "Rekenwaarde h(IIv->IIIv)"); - MapFeaturesMetaDataTestHelper.AssertMetaData( - GetExpectedWaterLevel(failureMechanism.CalculationsForMechanismSpecificLowerLimitNorm, expectedDuneLocation), - mapFeature, "Rekenwaarde h(IIIv->IVv)"); - MapFeaturesMetaDataTestHelper.AssertMetaData( - GetExpectedWaterLevel(failureMechanism.CalculationsForLowerLimitNorm, expectedDuneLocation), - mapFeature, "Rekenwaarde h(IVv->Vv)"); - MapFeaturesMetaDataTestHelper.AssertMetaData( - GetExpectedWaterLevel(failureMechanism.CalculationsForFactorizedLowerLimitNorm, expectedDuneLocation), - mapFeature, "Rekenwaarde h(Vv->VIv)"); - - MapFeaturesMetaDataTestHelper.AssertMetaData( - GetExpectedWaveHeight(failureMechanism.CalculationsForMechanismSpecificFactorizedSignalingNorm, expectedDuneLocation), - mapFeature, "Rekenwaarde Hs(Iv->IIv)"); - MapFeaturesMetaDataTestHelper.AssertMetaData( - GetExpectedWaveHeight(failureMechanism.CalculationsForMechanismSpecificSignalingNorm, expectedDuneLocation), - mapFeature, "Rekenwaarde Hs(IIv->IIIv)"); - MapFeaturesMetaDataTestHelper.AssertMetaData( - GetExpectedWaveHeight(failureMechanism.CalculationsForMechanismSpecificLowerLimitNorm, expectedDuneLocation), - mapFeature, "Rekenwaarde Hs(IIIv->IVv)"); - MapFeaturesMetaDataTestHelper.AssertMetaData( - GetExpectedWaveHeight(failureMechanism.CalculationsForLowerLimitNorm, expectedDuneLocation), - mapFeature, "Rekenwaarde Hs(IVv->Vv)"); - MapFeaturesMetaDataTestHelper.AssertMetaData( - GetExpectedWaveHeight(failureMechanism.CalculationsForFactorizedLowerLimitNorm, expectedDuneLocation), - mapFeature, "Rekenwaarde Hs(Vv->VIv)"); - - MapFeaturesMetaDataTestHelper.AssertMetaData( - GetExpectedWavePeriod(failureMechanism.CalculationsForMechanismSpecificFactorizedSignalingNorm, expectedDuneLocation), - mapFeature, "Rekenwaarde Tp(Iv->IIv)"); - MapFeaturesMetaDataTestHelper.AssertMetaData( - GetExpectedWavePeriod(failureMechanism.CalculationsForMechanismSpecificSignalingNorm, expectedDuneLocation), - mapFeature, "Rekenwaarde Tp(IIv->IIIv)"); - MapFeaturesMetaDataTestHelper.AssertMetaData( - GetExpectedWavePeriod(failureMechanism.CalculationsForMechanismSpecificLowerLimitNorm, expectedDuneLocation), - mapFeature, "Rekenwaarde Tp(IIIv->IVv)"); - MapFeaturesMetaDataTestHelper.AssertMetaData( - GetExpectedWavePeriod(failureMechanism.CalculationsForLowerLimitNorm, expectedDuneLocation), - mapFeature, "Rekenwaarde Tp(IVv->Vv)"); - MapFeaturesMetaDataTestHelper.AssertMetaData( - GetExpectedWavePeriod(failureMechanism.CalculationsForFactorizedLowerLimitNorm, expectedDuneLocation), - mapFeature, "Rekenwaarde Tp(Vv->VIv)"); - - Assert.AreEqual(19, mapFeature.MetaData.Keys.Count); - } + DuneErosionMapFeaturesTestHelper.AssertDuneLocationFeaturesData(failureMechanism, features); } private static DuneLocation CreateDuneLocation(int seed) @@ -257,36 +195,6 @@ }); } - private static string GetExpectedWaterLevel(IEnumerable calculations, - DuneLocation duneLocation) - { - RoundedDouble result = calculations - .Single(calculation => calculation.DuneLocation.Equals(duneLocation)) - .Output?.WaterLevel ?? RoundedDouble.NaN; - - return result.ToString(); - } - - private static string GetExpectedWaveHeight(IEnumerable calculations, - DuneLocation duneLocation) - { - RoundedDouble result = calculations - .Single(calculation => calculation.DuneLocation.Equals(duneLocation)) - .Output?.WaveHeight ?? RoundedDouble.NaN; - - return result.ToString(); - } - - private static string GetExpectedWavePeriod(IEnumerable calculations, - DuneLocation duneLocation) - { - RoundedDouble result = calculations - .Single(calculation => calculation.DuneLocation.Equals(duneLocation)) - .Output?.WavePeriod ?? RoundedDouble.NaN; - - return result.ToString(); - } - private class ValidDuneLocation : DuneLocation { public ValidDuneLocation(Point2D location) : base(0, "", location, new ConstructionProperties()) {} Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Ringtoets.DuneErosion.Forms.Test.csproj =================================================================== diff -u -r96ac681afe124833d844548e00dee33c5aa81414 -r89931b99566016e46b0f5389b0d92168d303b1c1 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Ringtoets.DuneErosion.Forms.Test.csproj (.../Ringtoets.DuneErosion.Forms.Test.csproj) (revision 96ac681afe124833d844548e00dee33c5aa81414) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.Test/Ringtoets.DuneErosion.Forms.Test.csproj (.../Ringtoets.DuneErosion.Forms.Test.csproj) (revision 89931b99566016e46b0f5389b0d92168d303b1c1) @@ -142,6 +142,10 @@ {7be6b522-02e3-4143-8508-c021a211de54} Ringtoets.DuneErosion.Data.TestUtil + + {AB95EC86-28CF-47E6-ABB0-927EBBE61445} + Ringtoets.DuneErosion.Forms.TestUtil + Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.TestUtil/DuneErosionMapFeaturesTestHelper.cs =================================================================== diff -u --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.TestUtil/DuneErosionMapFeaturesTestHelper.cs (revision 0) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.TestUtil/DuneErosionMapFeaturesTestHelper.cs (revision 89931b99566016e46b0f5389b0d92168d303b1c1) @@ -0,0 +1,152 @@ +// Copyright (C) Stichting Deltares 2017. 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.Collections.Generic; +using System.Globalization; +using System.Linq; +using Core.Common.Base.Data; +using Core.Components.Gis.Features; +using NUnit.Framework; +using Ringtoets.Common.Util.TestUtil; +using Ringtoets.DuneErosion.Data; + +namespace Ringtoets.DuneErosion.Forms.TestUtil +{ + /// + /// Class that can be used to test properties of a + /// + public static class DuneErosionMapFeaturesTestHelper + { + /// + /// Asserts whether contains the data that is representative for the data of + /// dune locations and calculations in . + /// + /// The failure mechanism that contains the first part of the original data. + /// Thrown when: + /// + /// the number of dune locations and features are not the same; + /// the general properties (such as id, name and location) of dune locations and features + /// are not the same; + /// the water level, wave height or wave period calculation results of a dune location and the + /// respective outputs of a corresponding feature are not the same. + /// the number of meta data items does not match with the expected number of items. + /// + /// + public static void AssertDuneLocationFeaturesData(DuneErosionFailureMechanism failureMechanism, + IEnumerable features) + { + IEnumerable expectedDuneLocations = failureMechanism.DuneLocations; + + Assert.AreEqual(expectedDuneLocations.Count(), features.Count()); + for (var i = 0; i < expectedDuneLocations.Count(); i++) + { + DuneLocation expectedDuneLocation = expectedDuneLocations.ElementAt(i); + MapFeature mapFeature = features.ElementAt(i); + + Assert.AreEqual(expectedDuneLocation.Id, mapFeature.MetaData["ID"]); + Assert.AreEqual(expectedDuneLocation.Name, mapFeature.MetaData["Naam"]); + Assert.AreEqual(expectedDuneLocation.CoastalAreaId, mapFeature.MetaData["Kustvaknummer"]); + Assert.AreEqual(expectedDuneLocation.Offset.ToString("0.#", CultureInfo.InvariantCulture), mapFeature.MetaData["Metrering"]); + Assert.AreEqual(expectedDuneLocation.Location, mapFeature.MapGeometries.First().PointCollections.First().Single()); + + MapFeaturesMetaDataTestHelper.AssertMetaData( + GetExpectedWaterLevel(failureMechanism.CalculationsForMechanismSpecificFactorizedSignalingNorm, expectedDuneLocation), + mapFeature, "Rekenwaarde h(Iv->IIv)"); + MapFeaturesMetaDataTestHelper.AssertMetaData( + GetExpectedWaterLevel(failureMechanism.CalculationsForMechanismSpecificSignalingNorm, expectedDuneLocation), + mapFeature, "Rekenwaarde h(IIv->IIIv)"); + MapFeaturesMetaDataTestHelper.AssertMetaData( + GetExpectedWaterLevel(failureMechanism.CalculationsForMechanismSpecificLowerLimitNorm, expectedDuneLocation), + mapFeature, "Rekenwaarde h(IIIv->IVv)"); + MapFeaturesMetaDataTestHelper.AssertMetaData( + GetExpectedWaterLevel(failureMechanism.CalculationsForLowerLimitNorm, expectedDuneLocation), + mapFeature, "Rekenwaarde h(IVv->Vv)"); + MapFeaturesMetaDataTestHelper.AssertMetaData( + GetExpectedWaterLevel(failureMechanism.CalculationsForFactorizedLowerLimitNorm, expectedDuneLocation), + mapFeature, "Rekenwaarde h(Vv->VIv)"); + + MapFeaturesMetaDataTestHelper.AssertMetaData( + GetExpectedWaveHeight(failureMechanism.CalculationsForMechanismSpecificFactorizedSignalingNorm, expectedDuneLocation), + mapFeature, "Rekenwaarde Hs(Iv->IIv)"); + MapFeaturesMetaDataTestHelper.AssertMetaData( + GetExpectedWaveHeight(failureMechanism.CalculationsForMechanismSpecificSignalingNorm, expectedDuneLocation), + mapFeature, "Rekenwaarde Hs(IIv->IIIv)"); + MapFeaturesMetaDataTestHelper.AssertMetaData( + GetExpectedWaveHeight(failureMechanism.CalculationsForMechanismSpecificLowerLimitNorm, expectedDuneLocation), + mapFeature, "Rekenwaarde Hs(IIIv->IVv)"); + MapFeaturesMetaDataTestHelper.AssertMetaData( + GetExpectedWaveHeight(failureMechanism.CalculationsForLowerLimitNorm, expectedDuneLocation), + mapFeature, "Rekenwaarde Hs(IVv->Vv)"); + MapFeaturesMetaDataTestHelper.AssertMetaData( + GetExpectedWaveHeight(failureMechanism.CalculationsForFactorizedLowerLimitNorm, expectedDuneLocation), + mapFeature, "Rekenwaarde Hs(Vv->VIv)"); + + MapFeaturesMetaDataTestHelper.AssertMetaData( + GetExpectedWavePeriod(failureMechanism.CalculationsForMechanismSpecificFactorizedSignalingNorm, expectedDuneLocation), + mapFeature, "Rekenwaarde Tp(Iv->IIv)"); + MapFeaturesMetaDataTestHelper.AssertMetaData( + GetExpectedWavePeriod(failureMechanism.CalculationsForMechanismSpecificSignalingNorm, expectedDuneLocation), + mapFeature, "Rekenwaarde Tp(IIv->IIIv)"); + MapFeaturesMetaDataTestHelper.AssertMetaData( + GetExpectedWavePeriod(failureMechanism.CalculationsForMechanismSpecificLowerLimitNorm, expectedDuneLocation), + mapFeature, "Rekenwaarde Tp(IIIv->IVv)"); + MapFeaturesMetaDataTestHelper.AssertMetaData( + GetExpectedWavePeriod(failureMechanism.CalculationsForLowerLimitNorm, expectedDuneLocation), + mapFeature, "Rekenwaarde Tp(IVv->Vv)"); + MapFeaturesMetaDataTestHelper.AssertMetaData( + GetExpectedWavePeriod(failureMechanism.CalculationsForFactorizedLowerLimitNorm, expectedDuneLocation), + mapFeature, "Rekenwaarde Tp(Vv->VIv)"); + + Assert.AreEqual(19, mapFeature.MetaData.Keys.Count); + } + } + + private static string GetExpectedWaterLevel(IEnumerable calculations, + DuneLocation duneLocation) + { + RoundedDouble result = calculations + .Single(calculation => calculation.DuneLocation.Equals(duneLocation)) + .Output?.WaterLevel ?? RoundedDouble.NaN; + + return result.ToString(); + } + + private static string GetExpectedWaveHeight(IEnumerable calculations, + DuneLocation duneLocation) + { + RoundedDouble result = calculations + .Single(calculation => calculation.DuneLocation.Equals(duneLocation)) + .Output?.WaveHeight ?? RoundedDouble.NaN; + + return result.ToString(); + } + + private static string GetExpectedWavePeriod(IEnumerable calculations, + DuneLocation duneLocation) + { + RoundedDouble result = calculations + .Single(calculation => calculation.DuneLocation.Equals(duneLocation)) + .Output?.WavePeriod ?? RoundedDouble.NaN; + + return result.ToString(); + } + } +} \ No newline at end of file Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.TestUtil/Ringtoets.DuneErosion.Forms.TestUtil.csproj =================================================================== diff -u -rf3717c59b89fc9dddecceddd52b7c4f2a563b432 -r89931b99566016e46b0f5389b0d92168d303b1c1 --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.TestUtil/Ringtoets.DuneErosion.Forms.TestUtil.csproj (.../Ringtoets.DuneErosion.Forms.TestUtil.csproj) (revision f3717c59b89fc9dddecceddd52b7c4f2a563b432) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.TestUtil/Ringtoets.DuneErosion.Forms.TestUtil.csproj (.../Ringtoets.DuneErosion.Forms.TestUtil.csproj) (revision 89931b99566016e46b0f5389b0d92168d303b1c1) @@ -7,11 +7,40 @@ + Copying.licenseheader + + + + {3BBFD65B-B277-4E50-AE6D-BD24C3434609} + Core.Common.Base + + + {318BA582-88C9-4816-A54A-A7E431461DE3} + Core.Components.Gis + + + {d4200f43-3f72-4f42-af0a-8ced416a38ec} + Ringtoets.Common.Data + + + {54DF6303-BF9A-4AE9-BE09-4AF50EF27412} + Ringtoets.Common.Util.TestUtil + + + {D1068432-C172-4AA6-847B-D9DEB4C6DE26} + Ringtoets.DuneErosion.Data + + + + + ..\..\..\..\packages\NUnit.3.8.1\lib\net40\nunit.framework.dll + + \ No newline at end of file Index: Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.TestUtil/packages.config =================================================================== diff -u --- Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.TestUtil/packages.config (revision 0) +++ Ringtoets/DuneErosion/test/Ringtoets.DuneErosion.Forms.TestUtil/packages.config (revision 89931b99566016e46b0f5389b0d92168d303b1c1) @@ -0,0 +1,26 @@ + + + + + \ No newline at end of file