Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsMapDataFeaturesFactoryTest.cs =================================================================== diff -u -r07e54440666b51d4a93039da2f8b5fa031fe4fe2 -rb248ec9d8b1ef036e7355d351a08be673dce3ec1 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsMapDataFeaturesFactoryTest.cs (.../RingtoetsMapDataFeaturesFactoryTest.cs) (revision 07e54440666b51d4a93039da2f8b5fa031fe4fe2) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/Views/RingtoetsMapDataFeaturesFactoryTest.cs (.../RingtoetsMapDataFeaturesFactoryTest.cs) (revision b248ec9d8b1ef036e7355d351a08be673dce3ec1) @@ -19,9 +19,11 @@ // 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 Core.Common.Base.Geometry; +using Core.Common.TestUtil; using Core.Components.Gis.Features; using Core.Components.Gis.Geometries; using NUnit.Framework; @@ -37,6 +39,66 @@ public class RingtoetsMapDataFeaturesFactoryTest { [Test] + public void MapCalculationDataConstructor_WithoutName_ThrowArgumentNullException() + { + // Setup + var calculationLocation = new Point2D(0.0, 2.3); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0.1, 2.3); + + // Call + TestDelegate test = () => new RingtoetsMapDataFeaturesFactory.MapCalculationData( + null, + calculationLocation, + hydraulicBoundaryLocation); + + // Assert + var paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "A calculation name is required.") + .ParamName; + + Assert.AreEqual("calculationName", paramName); + } + + [Test] + public void MapCalculationDataConstructor_WithoutCalculationLocation_ThrowArgumentNullException() + { + // Setup + var calculationName = "name"; + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, string.Empty, 0.1, 2.3); + + // Call + TestDelegate test = () => new RingtoetsMapDataFeaturesFactory.MapCalculationData( + calculationName, + null, + hydraulicBoundaryLocation); + + // Assert + var paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "A location for the calculation is required.") + .ParamName; + + Assert.AreEqual("calculationLocation", paramName); + } + + [Test] + public void MapCalculationDataConstructor_WithoutHydraulicBoundaryLocation_ThrowArgumentNullException() + { + // Setup + var calculationName = "name"; + var calculationLocation = new Point2D(0.0, 2.3); + + // Call + TestDelegate test = () => new RingtoetsMapDataFeaturesFactory.MapCalculationData( + calculationName, + calculationLocation, + null); + + // Assert + var paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage(test, "A hydraulic boundary location is required.") + .ParamName; + + Assert.AreEqual("hydraulicBoundaryLocation", paramName); + } + + [Test] public void CreateReferenceLineFeatures_ReferenceLineNull_ReturnsEmptyFeaturesArray() { // Call @@ -312,6 +374,62 @@ } [Test] + public void CreateCalculationsFeatures_NullLocations_ReturnsEmptyCollection() + { + // Call + MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateCalculationsFeatures(null); + + // Assert + Assert.IsEmpty(features); + } + + [Test] + public void CreateCalculationsFeatures_EmptyLocations_ReturnsEmptyCollection() + { + // Call + MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateCalculationsFeatures( + Enumerable.Empty()); + + // Assert + Assert.IsEmpty(features); + } + + [Test] + public void CreateCalculationsFeatures_WithCalculations_ReturnsCollectionWithCalculations() + { + // Setup + var calculationLocationA = new Point2D(1.2, 2.3); + var calculationLocationB = new Point2D(2.7, 2.0); + + var hydraulicBoundaryLocationA = new HydraulicBoundaryLocation(1, string.Empty, 1.3, 2.3); + var hydraulicBoundaryLocationB = new HydraulicBoundaryLocation(1, string.Empty, 7.7, 12.6); + + // Call + MapFeature[] features = RingtoetsMapDataFeaturesFactory.CreateCalculationsFeatures(new [] { + new RingtoetsMapDataFeaturesFactory.MapCalculationData("calculationA", calculationLocationA, hydraulicBoundaryLocationA), + new RingtoetsMapDataFeaturesFactory.MapCalculationData("calculationB", calculationLocationB, hydraulicBoundaryLocationB) + }); + + // Assert + Assert.AreEqual(2, features.Length); + Assert.AreEqual(1, features[0].MapGeometries.Count()); + Assert.AreEqual(1, features[1].MapGeometries.Count()); + var mapDataGeometryOne = features[0].MapGeometries.ElementAt(0).PointCollections.First().ToArray(); + var mapDataGeometryTwo = features[1].MapGeometries.ElementAt(0).PointCollections.First().ToArray(); + + CollectionElementsAlmostEquals(new[] + { + calculationLocationA, + hydraulicBoundaryLocationA.Location + }, mapDataGeometryOne); + CollectionElementsAlmostEquals(new[] + { + calculationLocationB, + hydraulicBoundaryLocationB.Location + }, mapDataGeometryTwo); + } + + [Test] public void CreateDikeProfilesFeatures_NullDikeProfiles_ReturnsEmptyCollection() { // Call @@ -333,7 +451,7 @@ } [Test] - public void CreateDikeProfilesFeatures_WithDikeProfiles_ReturnsCollectionWithForeshoreProfileAndDikeProfile() + public void CreateDikeProfilesFeatures_WithDikeProfiles_ReturnsCollectionWithDikeProfiles() { // Setup var pointA = new Point2D(1.2, 2.3); @@ -415,7 +533,7 @@ } [Test] - public void CreateForeshoreProfilesFeatures_WithForeshoreProfiles_ReturnsCollectionWithForeshoreProfileAndForeshoreProfile() + public void CreateForeshoreProfilesFeatures_WithForeshoreProfiles_ReturnsCollectionWithForeshoreProfiles() { // Setup var pointA = new Point2D(1.2, 2.3);