Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismViewTest.cs =================================================================== diff -u -r7019db1a51efdb9f1bd955015fcff3b756a8ed1f -rd32eef17c3a48ff9b0cfce71088e912b1b5bb8c0 --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismViewTest.cs (.../ClosingStructuresFailureMechanismViewTest.cs) (revision 7019db1a51efdb9f1bd955015fcff3b756a8ed1f) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Forms.Test/Views/ClosingStructuresFailureMechanismViewTest.cs (.../ClosingStructuresFailureMechanismViewTest.cs) (revision d32eef17c3a48ff9b0cfce71088e912b1b5bb8c0) @@ -32,7 +32,6 @@ using Ringtoets.ClosingStructures.Data.TestUtil; using Ringtoets.ClosingStructures.Forms.PresentationObjects; using Ringtoets.ClosingStructures.Forms.Views; -using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Hydraulics; @@ -612,14 +611,16 @@ MapData structuresData = map.Data.Collection.ElementAt(structuresIndex); // Precondition - AssertStructures(failureMechanism.ClosingStructures, structuresData); + MapDataTestHelper.AssertStructuresMapData(failureMechanism.ClosingStructures, + structuresData); // Call structure.CopyProperties(new TestClosingStructure(new Point2D(1, 1), "Id")); structure.NotifyObservers(); // Assert - AssertStructures(failureMechanism.ClosingStructures, structuresData); + MapDataTestHelper.AssertStructuresMapData(failureMechanism.ClosingStructures, + structuresData); } } @@ -645,7 +646,8 @@ MapData structuresData = map.Data.Collection.ElementAt(structuresIndex); // Precondition - AssertStructures(failureMechanism.ClosingStructures, structuresData); + MapDataTestHelper.AssertStructuresMapData(failureMechanism.ClosingStructures, + structuresData); // Call failureMechanism.ClosingStructures.AddRange(new[] @@ -655,7 +657,8 @@ failureMechanism.ClosingStructures.NotifyObservers(); // Assert - AssertStructures(failureMechanism.ClosingStructures, structuresData); + MapDataTestHelper.AssertStructuresMapData(failureMechanism.ClosingStructures, + structuresData); } } @@ -930,24 +933,6 @@ } } - private static void AssertStructures(IEnumerable structures, MapData mapData) - { - Assert.NotNull(structures, "structures should never be null."); - - var structuresData = (MapPointData) mapData; - StructureBase[] structuresArray = structures.ToArray(); - - Assert.AreEqual(structuresArray.Length, structuresData.Features.Length); - - for (var i = 0; i < structuresArray.Length; i++) - { - MapGeometry profileDataA = structuresData.Features[i].MapGeometries.First(); - Assert.AreEqual(structuresArray[i].Location, profileDataA.PointCollections.First().First()); - } - - Assert.AreEqual("Kunstwerken", mapData.Name); - } - private static void AssertCalculationsMapData(IEnumerable> calculations, MapData mapData) { Assert.IsInstanceOf(mapData); Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj =================================================================== diff -u -rf411570487c2c859af89b0cefd544386a6a60c15 -rd32eef17c3a48ff9b0cfce71088e912b1b5bb8c0 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj (.../Ringtoets.Common.Data.TestUtil.Test.csproj) (revision f411570487c2c859af89b0cefd544386a6a60c15) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/Ringtoets.Common.Data.TestUtil.Test.csproj (.../Ringtoets.Common.Data.TestUtil.Test.csproj) (revision d32eef17c3a48ff9b0cfce71088e912b1b5bb8c0) @@ -69,6 +69,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/TestStructureTest.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/TestStructureTest.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/TestStructureTest.cs (revision d32eef17c3a48ff9b0cfce71088e912b1b5bb8c0) @@ -0,0 +1,61 @@ +// 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 Core.Common.Base.Geometry; +using NUnit.Framework; + +namespace Ringtoets.Common.Data.TestUtil.Test +{ + [TestFixture] + public class TestStructureTest + { + [Test] + public void Constructor_ExpectedProperties() + { + // Call + var structure = new TestStructure(); + + // Assert + Assert.AreEqual("name", structure.Name); + Assert.AreEqual("id", structure.Id); + Assert.AreEqual(new Point2D(0.0, 0.0), structure.Location); + Assert.AreEqual(0.12345, structure.StructureNormalOrientation, + structure.StructureNormalOrientation.GetAccuracy()); + } + + [Test] + public void Point2DConstructor_ExpectedProperties() + { + // Setup + var location = new Point2D(1, 1); + + // Call + var structure = new TestStructure(location); + + // Assert + Assert.AreEqual("name", structure.Name); + Assert.AreEqual("id", structure.Id); + Assert.AreEqual(location, structure.Location); + Assert.AreEqual(0.12345, structure.StructureNormalOrientation, + structure.StructureNormalOrientation.GetAccuracy()); + } + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/Ringtoets.Common.Data.TestUtil.csproj =================================================================== diff -u -rf411570487c2c859af89b0cefd544386a6a60c15 -rd32eef17c3a48ff9b0cfce71088e912b1b5bb8c0 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/Ringtoets.Common.Data.TestUtil.csproj (.../Ringtoets.Common.Data.TestUtil.csproj) (revision f411570487c2c859af89b0cefd544386a6a60c15) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/Ringtoets.Common.Data.TestUtil.csproj (.../Ringtoets.Common.Data.TestUtil.csproj) (revision d32eef17c3a48ff9b0cfce71088e912b1b5bb8c0) @@ -71,6 +71,7 @@ + Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/TestStructure.cs =================================================================== diff -u --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/TestStructure.cs (revision 0) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/TestStructure.cs (revision d32eef17c3a48ff9b0cfce71088e912b1b5bb8c0) @@ -0,0 +1,55 @@ +// 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; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; + +namespace Ringtoets.Common.Data.TestUtil +{ + /// + /// for testing purposes. + /// + public class TestStructure : StructureBase + { + /// + /// Creates a new instance of . + /// + public TestStructure() : this("name", "id", new Point2D(0.0, 0.0)) {} + + /// + /// Creates a new instance of . + /// + /// The location of the structure. + /// Thrown when + /// is null. + public TestStructure(Point2D location) : this("name", "id", location) {} + + private TestStructure(string name, string id, Point2D location) + : base(new ConstructionProperties + { + Name = name, + Id = id, + Location = location, + StructureNormalOrientation = (RoundedDouble) 0.12345 + }) {} + } +} \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/MapDataTestHelperTest.cs =================================================================== diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -rd32eef17c3a48ff9b0cfce71088e912b1b5bb8c0 --- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/MapDataTestHelperTest.cs (.../MapDataTestHelperTest.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/MapDataTestHelperTest.cs (.../MapDataTestHelperTest.cs) (revision d32eef17c3a48ff9b0cfce71088e912b1b5bb8c0) @@ -28,6 +28,7 @@ using Core.Components.Gis.Geometries; using Core.Components.Gis.TestUtil; using NUnit.Framework; +using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; @@ -1247,5 +1248,143 @@ } #endregion + + #region AssertStructuresMapData + + [Test] + public void AssertStructuresMapData_MapDataNotMapPointData_ThrowAssertionException() + { + // Setup + var mapData = new MapLineData("Kunstwerken"); + + // Call + TestDelegate test = () => MapDataTestHelper.AssertStructuresMapData(Enumerable.Empty(), mapData); + + // Assert + Assert.Throws(test); + } + + [Test] + public void AssertStructuresMapData_MapDataNameNotCorrect_ThrowAssertionException() + { + // Setup + var mapData = new MapPointData("Other name") + { + Features = new[] + { + new MapFeature(new[] + { + new MapGeometry(new[] + { + new[] + { + new Point2D(0, 0) + } + }) + }) + } + }; + var structures = new[] + { + new TestStructure(new Point2D(0, 0)) + }; + + // Call + TestDelegate test = () => MapDataTestHelper.AssertStructuresMapData(structures, mapData); + + // Assert + Assert.Throws(test); + } + + [Test] + public void AssertStructuresMapData_MapDataFeaturesLengthNotSameAsExpectedStructuresLength_ThrowsAssertionException() + { + // Setup + var mapData = new MapPointData("Kunstwerken") + { + Features = new[] + { + new MapFeature(Enumerable.Empty()) + } + }; + var structures = new[] + { + new TestStructure(), + new TestStructure() + }; + + // Call + TestDelegate test = () => MapDataTestHelper.AssertStructuresMapData(structures, mapData); + + // Assert + Assert.Throws(test); + } + + [Test] + public void AssertStructuresMapData_FeatureGeometryNotSameAsExpectedLocation_ThrowAssertionException() + { + // Setup + var mapData = new MapPointData("Kunstwerken") + { + Features = new[] + { + new MapFeature(new[] + { + new MapGeometry(new[] + { + new[] + { + new Point2D(0, 0) + } + }) + }) + } + }; + var structures = new[] + { + new TestStructure(new Point2D(1, 1)) + }; + + // Call + TestDelegate test = () => MapDataTestHelper.AssertStructuresMapData(structures, mapData); + + // Assert + Assert.Throws(test); + } + + [Test] + public void AssertStructuresMapData_DataCorrect_DoesNotThrow() + { + // Setup + var mapData = new MapPointData("Kunstwerken") + { + Features = new[] + { + new MapFeature(new[] + { + new MapGeometry(new[] + { + new[] + { + new Point2D(0, 0), + new Point2D(0, -1) + } + }) + }) + } + }; + var structures = new[] + { + new TestStructure(new Point2D(0, 0)) + }; + + // Call + TestDelegate test = () => MapDataTestHelper.AssertStructuresMapData(structures, mapData); + + // Assert + Assert.DoesNotThrow(test); + } + + #endregion } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/MapDataTestHelper.cs =================================================================== diff -u -rb3b6c13cf736c134476b3db34281332d01ca86b1 -rd32eef17c3a48ff9b0cfce71088e912b1b5bb8c0 --- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/MapDataTestHelper.cs (.../MapDataTestHelper.cs) (revision b3b6c13cf736c134476b3db34281332d01ca86b1) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/MapDataTestHelper.cs (.../MapDataTestHelper.cs) (revision d32eef17c3a48ff9b0cfce71088e912b1b5bb8c0) @@ -27,6 +27,7 @@ using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; using NUnit.Framework; +using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.FailureMechanism; @@ -258,6 +259,39 @@ Assert.Fail("Unsupported background configuration."); } + /// + /// Asserts whether the contains the data that is representative + /// for the . + /// + /// The structures that contain the original data. + /// The that needs to be asserted. + /// Thrown when: + /// + /// is not ; + /// the name of the is not Kunstwerken; + /// the amount of features in is not equal to the + /// amount of the ; + /// the geometries of the features in are not equal to + /// the expected geometry of the . + /// + /// + public static void AssertStructuresMapData(IEnumerable structures, MapData mapData) + { + Assert.IsInstanceOf(mapData); + Assert.AreEqual("Kunstwerken", mapData.Name); + + var structuresData = (MapPointData) mapData; + StructureBase[] structuresArray = structures.ToArray(); + + Assert.AreEqual(structuresArray.Length, structuresData.Features.Length); + + for (var i = 0; i < structuresArray.Length; i++) + { + MapGeometry profileDataA = structuresData.Features[i].MapGeometries.First(); + Assert.AreEqual(structuresArray[i].Location, profileDataA.PointCollections.First().First()); + } + } + private static Point2D[] GetWorldPoints(ForeshoreProfile foreshoreProfile) { return AdvancedMath2D.FromXToXY( Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismViewTest.cs =================================================================== diff -u -r06c3ea29cfced4bf3c52d1507b66752797fcfddd -rd32eef17c3a48ff9b0cfce71088e912b1b5bb8c0 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismViewTest.cs (.../HeightStructuresFailureMechanismViewTest.cs) (revision 06c3ea29cfced4bf3c52d1507b66752797fcfddd) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.Forms.Test/Views/HeightStructuresFailureMechanismViewTest.cs (.../HeightStructuresFailureMechanismViewTest.cs) (revision d32eef17c3a48ff9b0cfce71088e912b1b5bb8c0) @@ -28,7 +28,6 @@ using Core.Components.Gis.Forms; using Core.Components.Gis.Geometries; using NUnit.Framework; -using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Hydraulics; @@ -628,14 +627,16 @@ MapData structuresData = map.Data.Collection.ElementAt(structuresIndex); // Precondition - AssertStructures(failureMechanism.HeightStructures, structuresData); + MapDataTestHelper.AssertStructuresMapData(failureMechanism.HeightStructures, + structuresData); // Call structure.CopyProperties(new TestHeightStructure(new Point2D(1, 1), "Id")); structure.NotifyObservers(); // Assert - AssertStructures(failureMechanism.HeightStructures, structuresData); + MapDataTestHelper.AssertStructuresMapData(failureMechanism.HeightStructures, + structuresData); } } @@ -661,7 +662,8 @@ MapData structuresData = map.Data.Collection.ElementAt(structuresIndex); // Precondition - AssertStructures(failureMechanism.HeightStructures, structuresData); + MapDataTestHelper.AssertStructuresMapData(failureMechanism.HeightStructures, + structuresData); // Call failureMechanism.HeightStructures.AddRange(new[] @@ -671,7 +673,8 @@ failureMechanism.HeightStructures.NotifyObservers(); // Assert - AssertStructures(failureMechanism.HeightStructures, structuresData); + MapDataTestHelper.AssertStructuresMapData(failureMechanism.HeightStructures, + structuresData); } } @@ -954,24 +957,6 @@ } } - private static void AssertStructures(IEnumerable structures, MapData mapData) - { - Assert.NotNull(structures, "structures should never be null."); - - var structuresData = (MapPointData) mapData; - StructureBase[] structuresArray = structures.ToArray(); - - Assert.AreEqual(structuresArray.Length, structuresData.Features.Length); - - for (var i = 0; i < structuresArray.Length; i++) - { - MapGeometry profileDataA = structuresData.Features[i].MapGeometries.First(); - Assert.AreEqual(structuresArray[i].Location, profileDataA.PointCollections.First().First()); - } - - Assert.AreEqual("Kunstwerken", mapData.Name); - } - private static void AssertCalculationsMapData(IEnumerable> calculations, MapData mapData) { Assert.IsInstanceOf(mapData); Index: Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismViewTest.cs =================================================================== diff -u -r06c3ea29cfced4bf3c52d1507b66752797fcfddd -rd32eef17c3a48ff9b0cfce71088e912b1b5bb8c0 --- Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismViewTest.cs (.../StabilityPointStructuresFailureMechanismViewTest.cs) (revision 06c3ea29cfced4bf3c52d1507b66752797fcfddd) +++ Ringtoets/StabilityPointStructures/test/Ringtoets.StabilityPointStructures.Forms.Test/Views/StabilityPointStructuresFailureMechanismViewTest.cs (.../StabilityPointStructuresFailureMechanismViewTest.cs) (revision d32eef17c3a48ff9b0cfce71088e912b1b5bb8c0) @@ -28,7 +28,6 @@ using Core.Components.Gis.Forms; using Core.Components.Gis.Geometries; using NUnit.Framework; -using Ringtoets.Common.Data; using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.FailureMechanism; using Ringtoets.Common.Data.Hydraulics; @@ -609,14 +608,16 @@ MapData structuresData = map.Data.Collection.ElementAt(structuresIndex); // Precondition - AssertStructures(failureMechanism.StabilityPointStructures, structuresData); + MapDataTestHelper.AssertStructuresMapData(failureMechanism.StabilityPointStructures, + structuresData); // Call structure.CopyProperties(new TestStabilityPointStructure(new Point2D(1, 1), "Id")); structure.NotifyObservers(); // Assert - AssertStructures(failureMechanism.StabilityPointStructures, structuresData); + MapDataTestHelper.AssertStructuresMapData(failureMechanism.StabilityPointStructures, + structuresData); } } @@ -640,15 +641,17 @@ MapData structuresData = map.Data.Collection.ElementAt(structuresIndex); // Precondition - AssertStructures(failureMechanism.StabilityPointStructures, structuresData); + MapDataTestHelper.AssertStructuresMapData(failureMechanism.StabilityPointStructures, + structuresData); // Call failureMechanism.StabilityPointStructures.Add( new TestStabilityPointStructure(new Point2D(1, 1), "Id2")); failureMechanism.StabilityPointStructures.NotifyObservers(); // Assert - AssertStructures(failureMechanism.StabilityPointStructures, structuresData); + MapDataTestHelper.AssertStructuresMapData(failureMechanism.StabilityPointStructures, + structuresData); } } @@ -923,24 +926,6 @@ } } - private static void AssertStructures(IEnumerable structures, MapData mapData) - { - Assert.NotNull(structures, "structures should never be null."); - - var structuresData = (MapPointData) mapData; - StructureBase[] structuresArray = structures.ToArray(); - - Assert.AreEqual(structuresArray.Length, structuresData.Features.Length); - - for (var i = 0; i < structuresArray.Length; i++) - { - MapGeometry profileDataA = structuresData.Features[i].MapGeometries.First(); - Assert.AreEqual(structuresArray[i].Location, profileDataA.PointCollections.First().First()); - } - - Assert.AreEqual("Kunstwerken", mapData.Name); - } - private static void AssertCalculationsMapData(IEnumerable> calculations, MapData mapData) { Assert.IsInstanceOf(mapData);