Index: Ringtoets/Common/test/Ringtoets.Common.Data.Test/UpdateDataStrategies/UpdateDataStrategyBaseTest.cs =================================================================== diff -u -re3ec5f4669022733a11c4c3070747331bf36056f -r6a28e1aa3e370ae901e184ce6b511b0271228d13 --- Ringtoets/Common/test/Ringtoets.Common.Data.Test/UpdateDataStrategies/UpdateDataStrategyBaseTest.cs (.../UpdateDataStrategyBaseTest.cs) (revision e3ec5f4669022733a11c4c3070747331bf36056f) +++ Ringtoets/Common/test/Ringtoets.Common.Data.Test/UpdateDataStrategies/UpdateDataStrategyBaseTest.cs (.../UpdateDataStrategyBaseTest.cs) (revision 6a28e1aa3e370ae901e184ce6b511b0271228d13) @@ -39,7 +39,7 @@ public void DefaultConstructor_FailureMechanismNull_ThrowsArgumentNullException() { // Call - TestDelegate call = () => new ConcreteUpdateDataStrategy(null); + TestDelegate call = () => new TestUpdateDataStrategy(null); // Assert string paramName = Assert.Throws(call).ParamName; @@ -50,7 +50,7 @@ public void DefaultConstructor_EqualityComparerNull_ThrowsArgumentNullException() { // Call - TestDelegate call = () => new ConcreteUpdateDataStrategy(new TestFailureMechanism(), null); + TestDelegate call = () => new TestUpdateDataStrategy(new TestFailureMechanism(), null); // Assert string paramName = Assert.Throws(call).ParamName; @@ -61,7 +61,7 @@ public void DefaultConstructor_FailureMechanismNotNull_DoesNotThrowException() { // Call - TestDelegate call = () => new ConcreteUpdateDataStrategy(new TestFailureMechanism()); + TestDelegate call = () => new TestUpdateDataStrategy(new TestFailureMechanism()); // Assert Assert.DoesNotThrow(call); @@ -71,7 +71,7 @@ public void UpdateTargetCollectionData_TargetCollectionNull_ThrowsArgumentNullException() { // Setup - var strategy = new ConcreteUpdateDataStrategy(new TestFailureMechanism()); + var strategy = new TestUpdateDataStrategy(new TestFailureMechanism()); // Call TestDelegate call = () => strategy.ConcreteUpdateData(null, Enumerable.Empty(), string.Empty); @@ -85,7 +85,7 @@ public void UpdateTargetCollectionData_ImportedDataCollectionNull_ThrowsArgumentNullException() { // Setup - var strategy = new ConcreteUpdateDataStrategy(new TestFailureMechanism()); + var strategy = new TestUpdateDataStrategy(new TestFailureMechanism()); var collection = new TestUniqueItemCollection(); // Call @@ -100,7 +100,7 @@ public void UpdateTargetCollectionData_SourceFilePathNull_ThrowsArgumentNullException() { // Setup - var strategy = new ConcreteUpdateDataStrategy(new TestFailureMechanism()); + var strategy = new TestUpdateDataStrategy(new TestFailureMechanism()); var collection = new TestUniqueItemCollection(); // Call @@ -118,7 +118,7 @@ var collection = new TestUniqueItemCollection(); const string filePath = "path"; - var strategy = new ConcreteUpdateDataStrategy(new TestFailureMechanism()); + var strategy = new TestUpdateDataStrategy(new TestFailureMechanism()); // Call IEnumerable affectedObjects = strategy.ConcreteUpdateData(collection, Enumerable.Empty(), filePath); @@ -145,7 +145,7 @@ }; collection.AddRange(itemsRemoved, filePath); - var strategy = new ConcreteUpdateDataStrategy(new TestFailureMechanism()) + var strategy = new TestUpdateDataStrategy(new TestFailureMechanism()) { ItemsToRemove = itemsRemoved }; @@ -186,7 +186,7 @@ new TestItem("Name B") }; - var strategy = new ConcreteUpdateDataStrategy(new TestFailureMechanism()); + var strategy = new TestUpdateDataStrategy(new TestFailureMechanism()); // Call IEnumerable affectedObjects = strategy.ConcreteUpdateData(collection, importedItems, sourceFilePath); @@ -223,7 +223,7 @@ new TestItem(duplicateName) }; - var strategy = new ConcreteUpdateDataStrategy(new TestFailureMechanism()); + var strategy = new TestUpdateDataStrategy(new TestFailureMechanism()); // Call TestDelegate call = () => strategy.ConcreteUpdateData(collection, importedCollection, sourceFilePath); @@ -260,7 +260,7 @@ currentCollection[1].DeepClone() }; - var strategy = new ConcreteUpdateDataStrategy(new TestFailureMechanism()) + var strategy = new TestUpdateDataStrategy(new TestFailureMechanism()) { ItemsToUpdate = currentCollection }; @@ -307,7 +307,7 @@ currentCollection[1].DeepClone() }; - var strategy = new ConcreteUpdateDataStrategy(new TestFailureMechanism()) + var strategy = new TestUpdateDataStrategy(new TestFailureMechanism()) { ItemsToUpdate = currentCollection }; @@ -351,7 +351,7 @@ itemToAdd }; - var strategy = new ConcreteUpdateDataStrategy(new TestFailureMechanism()) + var strategy = new TestUpdateDataStrategy(new TestFailureMechanism()) { ItemsToUpdate = new[] { @@ -411,7 +411,7 @@ new TestItem("Item four") }; - var strategy = new ConcreteUpdateDataStrategy(new TestFailureMechanism()) + var strategy = new TestUpdateDataStrategy(new TestFailureMechanism()) { ItemsToRemove = currentCollection }; @@ -460,7 +460,7 @@ new TestItem(name) }; - var strategy = new ConcreteUpdateDataStrategy(new TestFailureMechanism()); + var strategy = new TestUpdateDataStrategy(new TestFailureMechanism()); // Call TestDelegate call = () => strategy.ConcreteUpdateData(collection, @@ -490,7 +490,7 @@ itemTwo }; - var strategy = new ConcreteUpdateDataStrategy(new TestFailureMechanism()) + var strategy = new TestUpdateDataStrategy(new TestFailureMechanism()) { ItemsToUpdate = currentCollection, ItemsToUpdateFrom = importedItems, @@ -512,14 +512,14 @@ CollectionAssert.AreEqual(expectedAffectedObjects, affectedObjects); } - private class ConcreteUpdateDataStrategy : UpdateDataStrategyBase + private class TestUpdateDataStrategy : UpdateDataStrategyBase { public bool AddObjectToUpdateToAffectedItems; - public ConcreteUpdateDataStrategy(TestFailureMechanism failureMechanism, IEqualityComparer comparer) + public TestUpdateDataStrategy(TestFailureMechanism failureMechanism, IEqualityComparer comparer) : base(failureMechanism, comparer) {} - public ConcreteUpdateDataStrategy(TestFailureMechanism failureMechanism) + public TestUpdateDataStrategy(TestFailureMechanism failureMechanism) : base(failureMechanism, new NameComparer()) {} public bool IsUpdateDataCalled { get; private set; } Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/TestStructureTest.cs =================================================================== diff -u -rdf53f0268b7c15f000796a38436b2c40069b9b07 -r6a28e1aa3e370ae901e184ce6b511b0271228d13 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/TestStructureTest.cs (.../TestStructureTest.cs) (revision df53f0268b7c15f000796a38436b2c40069b9b07) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/TestStructureTest.cs (.../TestStructureTest.cs) (revision 6a28e1aa3e370ae901e184ce6b511b0271228d13) @@ -30,12 +30,13 @@ public class TestStructureTest { [Test] - public void Constructor_ExpectedProperties() + public void DefaultConstructor_ExpectedProperties() { // Call var structure = new TestStructure(); // Assert + Assert.IsInstanceOf(structure); Assert.AreEqual("id", structure.Id); Assert.AreEqual("name", structure.Name); Assert.AreEqual(new Point2D(0.0, 0.0), structure.Location); @@ -44,7 +45,7 @@ } [Test] - public void IdConstructor_ValidParameters_ExpectedProperties() + public void Constructor_WithId_ExpectedProperties() { // Setup const string id = "some Id"; @@ -53,6 +54,7 @@ var structure = new TestStructure(id); // Assert + Assert.IsInstanceOf(structure); Assert.AreEqual(id, structure.Id); Assert.AreEqual("name", structure.Name); Assert.AreEqual(new Point2D(0.0, 0.0), structure.Location); @@ -64,7 +66,7 @@ [TestCase(null)] [TestCase("")] [TestCase(" ")] - public void IdConstructor_InvalidId_ThrowsArgumentException(string id) + public void Constructor_WithInvalidId_ThrowsArgumentException(string id) { // Call TestDelegate call = () => new TestStructure(id); @@ -74,7 +76,7 @@ } [Test] - public void IdNameConstructor_ValidParameters_ExpectedProperties() + public void Constructor_WithNameAndId_ExpectedProperties() { // Setup const string id = "some Id"; @@ -84,6 +86,7 @@ var structure = new TestStructure(id, name); // Assert + Assert.IsInstanceOf(structure); Assert.AreEqual(id, structure.Id); Assert.AreEqual(name, structure.Name); Assert.AreEqual(new Point2D(0.0, 0.0), structure.Location); @@ -95,7 +98,7 @@ [TestCase(null)] [TestCase("")] [TestCase(" ")] - public void IdNameConstructor_InvalidName_ThrowsArgumentException(string name) + public void Constructor_WithIdAndInvalidName_ThrowsArgumentException(string name) { // Setup const string id = "some Id"; @@ -108,16 +111,33 @@ } [Test] - public void IdLocationConstructor_ValidParameters_ExpectedProperties() + [TestCase(null)] + [TestCase("")] + [TestCase(" ")] + public void Constructor_WithNameAndInvalidId_ThrowsArgumentException(string id) { // Setup + const string name = "some Name"; + + // Call + TestDelegate call = () => new TestStructure(id, name); + + // Assert + Assert.Throws(call); + } + + [Test] + public void Constructor_WithIdAndLocation_ExpectedProperties() + { + // Setup const string id = "some Id"; var location = new Point2D(1, 1); // Call var structure = new TestStructure(id, location); // Assert + Assert.IsInstanceOf(structure); Assert.AreEqual(id, structure.Id); Assert.AreEqual("name", structure.Name); Assert.AreSame(location, structure.Location); @@ -129,7 +149,7 @@ [TestCase(null)] [TestCase("")] [TestCase(" ")] - public void IdLocationConstructor_InvalidId_ThrowsArgumentException(string id) + public void Constructor_WithLocationAndInvalidId_ThrowsArgumentException(string id) { // Setup var location = new Point2D(1, 1); @@ -142,7 +162,7 @@ } [Test] - public void IdLocationConstructor_LocationNull_ThrowsArgumentNullException() + public void Constructor_WithIdAndLocationNull_ThrowsArgumentNullException() { // Setup const string id = "some Id"; @@ -156,7 +176,7 @@ } [Test] - public void Point2DConstructor_ValidParameters_ExpectedProperties() + public void Constructor_WithLocation_ExpectedProperties() { // Setup var location = new Point2D(1, 1); @@ -165,6 +185,7 @@ var structure = new TestStructure(location); // Assert + Assert.IsInstanceOf(structure); Assert.AreEqual("id", structure.Id); Assert.AreEqual("name", structure.Name); Assert.AreSame(location, structure.Location); @@ -173,7 +194,7 @@ } [Test] - public void Point2DConstructor_LocationNull_ThrowsArgumentNullException() + public void Constructor_LocationNull_ThrowsArgumentNullException() { // Setup Point2D location = null; @@ -189,7 +210,7 @@ [TestCase(null)] [TestCase("")] [TestCase(" ")] - public void IdNamePoint2DConstructor_InvalidId_ThrowsArgumentException(string id) + public void Constructor_WithNameAndLocationAndInvalidId_ThrowsArgumentException(string id) { // Setup const string name = "some name"; @@ -206,7 +227,7 @@ [TestCase(null)] [TestCase("")] [TestCase(" ")] - public void IdNamePoint2DConstructor_InvalidName_ThrowsArgumentException(string name) + public void Constructor_WithIdAndLocationAndInvalidName_ThrowsArgumentException(string name) { // Setup const string id = "some id"; @@ -220,7 +241,7 @@ } [Test] - public void IdNamePoint2DConstructor_ValidParameters_ExpectedProperties() + public void Constructor_WithIdAndNameAndLocation_ExpectedProperties() { // Setup const string id = "some Id"; @@ -231,6 +252,7 @@ var structure = new TestStructure(id, name, location); // Assert + Assert.IsInstanceOf(structure); Assert.AreEqual(id, structure.Id); Assert.AreEqual(name, structure.Name); Assert.AreSame(location, structure.Location); @@ -239,7 +261,7 @@ } [Test] - public void IdNamePoint2DConstructor_LocationNull_ThrowsArgumentNullException() + public void Constructor_WithIdAndNameAndLocationNull_ThrowsArgumentNullException() { // Setup const string id = "some Id"; @@ -254,7 +276,7 @@ } [Test] - public void IdNamePoint2DNormalConstructor_ValidParameters_ExpectedProperties() + public void Constructor_WithIdAndNameAndLocationAndNormal_ExpectedProperties() { // Setup const string id = "some Id"; @@ -266,6 +288,7 @@ var structure = new TestStructure(id, name, location, normal); // Assert + Assert.IsInstanceOf(structure); Assert.AreEqual(id, structure.Id); Assert.AreEqual(name, structure.Name); Assert.AreSame(location, structure.Location); @@ -277,7 +300,7 @@ [TestCase(null)] [TestCase("")] [TestCase(" ")] - public void IdNamePoint2DNormalConstructor_InvalidId_ThrowsArgumentException(string id) + public void Constructor_WithNameAndLocationAndNormalAndInvalidId_ThrowsArgumentException(string id) { // Setup const string name = "some name"; @@ -295,7 +318,7 @@ [TestCase(null)] [TestCase("")] [TestCase(" ")] - public void IdNamePoint2DNormalConstructor_InvalidName_ThrowsArgumentException(string name) + public void Constructor_WithIdAndLocationAndNormalAndInvalidName_ThrowsArgumentException(string name) { // Setup const string id = "some Id"; @@ -310,7 +333,7 @@ } [Test] - public void IdNamePoint2DNormalConstructor_LocationNull_ThrowsArgumentNullException() + public void Constructor_WithIdAndNameAndNormalAndLocationNull_ThrowsArgumentNullException() { // Setup const string id = "some Id"; Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/MapDataTestHelperTest.cs =================================================================== diff -u -rd32eef17c3a48ff9b0cfce71088e912b1b5bb8c0 -r6a28e1aa3e370ae901e184ce6b511b0271228d13 --- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/MapDataTestHelperTest.cs (.../MapDataTestHelperTest.cs) (revision d32eef17c3a48ff9b0cfce71088e912b1b5bb8c0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil.Test/MapDataTestHelperTest.cs (.../MapDataTestHelperTest.cs) (revision 6a28e1aa3e370ae901e184ce6b511b0271228d13) @@ -1252,6 +1252,29 @@ #region AssertStructuresMapData [Test] + public void AssertStructuresMapData_StructuresNull_ThrowAssertionException() + { + // Setup + var mapData = new MapLineData("Kunstwerken"); + + // Call + TestDelegate test = () => MapDataTestHelper.AssertStructuresMapData(null, mapData); + + // Assert + Assert.Throws(test); + } + + [Test] + public void AssertStructuresMapData_MapDataNull_ThrowAssertionException() + { + // Call + TestDelegate test = () => MapDataTestHelper.AssertStructuresMapData(Enumerable.Empty(), null); + + // Assert + Assert.Throws(test); + } + + [Test] public void AssertStructuresMapData_MapDataNotMapPointData_ThrowAssertionException() { // Setup @@ -1353,7 +1376,7 @@ } [Test] - public void AssertStructuresMapData_DataCorrect_DoesNotThrow() + public void AssertStructuresMapData_MultiplePointsInGeometry_ThrowAssertionException() { // Setup var mapData = new MapPointData("Kunstwerken") @@ -1382,6 +1405,38 @@ 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) + } + }) + }) + } + }; + var structures = new[] + { + new TestStructure(new Point2D(0, 0)) + }; + + // Call + TestDelegate test = () => MapDataTestHelper.AssertStructuresMapData(structures, mapData); + + // Assert Assert.DoesNotThrow(test); } Index: Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/MapDataTestHelper.cs =================================================================== diff -u -rd32eef17c3a48ff9b0cfce71088e912b1b5bb8c0 -r6a28e1aa3e370ae901e184ce6b511b0271228d13 --- Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/MapDataTestHelper.cs (.../MapDataTestHelper.cs) (revision d32eef17c3a48ff9b0cfce71088e912b1b5bb8c0) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.TestUtil/MapDataTestHelper.cs (.../MapDataTestHelper.cs) (revision 6a28e1aa3e370ae901e184ce6b511b0271228d13) @@ -267,7 +267,8 @@ /// The that needs to be asserted. /// Thrown when: /// - /// is not ; + /// is not an instance of ; + /// is null. /// the name of the is not Kunstwerken; /// the amount of features in is not equal to the /// amount of the ; @@ -277,19 +278,16 @@ /// public static void AssertStructuresMapData(IEnumerable structures, MapData mapData) { + Assert.NotNull(structures); 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()); - } + CollectionAssert.AreEqual(structuresArray.Select(hrp => hrp.Location), + structuresData.Features.SelectMany(f => f.MapGeometries.First().PointCollections.First())); } private static Point2D[] GetWorldPoints(ForeshoreProfile foreshoreProfile)