Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/WindDirectionTestFactoryTest.cs =================================================================== diff -u -rb7988d7a5616c8c305dac4419a15d5eda07e88bc -r47ffe2caa64a35b18c61dfef4b795ab0f0f30bc1 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/WindDirectionTestFactoryTest.cs (.../WindDirectionTestFactoryTest.cs) (revision b7988d7a5616c8c305dac4419a15d5eda07e88bc) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil.Test/IllustrationPoints/WindDirectionTestFactoryTest.cs (.../WindDirectionTestFactoryTest.cs) (revision 47ffe2caa64a35b18c61dfef4b795ab0f0f30bc1) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using NUnit.Framework; using Ringtoets.Common.Data.IllustrationPoints; using Ringtoets.Common.Data.TestUtil.IllustrationPoints; @@ -40,5 +41,29 @@ Assert.AreEqual("SSE", windDirection.Name); Assert.AreEqual(5.0, windDirection.Angle, windDirection.Angle.GetAccuracy()); } + + [Test] + public void CreatesTestWindDirection_WindDirectionNull_ThrowsArgumentNullException() + { + // Call + TestDelegate call = () => WindDirectionTestFactory.CreateTestWindDirection(null); + + // Assert + var exception = Assert.Throws(call); + Assert.AreEqual("name", exception.ParamName); + } + + [Test] + [TestCase("")] + [TestCase("WindDirection")] + public void CreateTestWindDirection_WithWindDirection_ReturnsExpectedProperties(string windDirectionName) + { + // Call + WindDirection windDirection = WindDirectionTestFactory.CreateTestWindDirection(windDirectionName); + + // Assert + Assert.AreEqual(windDirectionName, windDirection.Name); + Assert.AreEqual(5.0, windDirection.Angle, windDirection.Angle.GetAccuracy()); + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/WindDirectionTestFactory.cs =================================================================== diff -u -rb7988d7a5616c8c305dac4419a15d5eda07e88bc -r47ffe2caa64a35b18c61dfef4b795ab0f0f30bc1 --- Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/WindDirectionTestFactory.cs (.../WindDirectionTestFactory.cs) (revision b7988d7a5616c8c305dac4419a15d5eda07e88bc) +++ Ringtoets/Common/test/Ringtoets.Common.Data.TestUtil/IllustrationPoints/WindDirectionTestFactory.cs (.../WindDirectionTestFactory.cs) (revision 47ffe2caa64a35b18c61dfef4b795ab0f0f30bc1) @@ -19,6 +19,7 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System; using Ringtoets.Common.Data.IllustrationPoints; namespace Ringtoets.Common.Data.TestUtil.IllustrationPoints @@ -32,9 +33,22 @@ /// Creates a new instance of with arbitrary values for /// wind direction name and angle. /// + /// A which can be readily used for testing. public static WindDirection CreateTestWindDirection() { return new WindDirection("SSE", 5.0); } + + /// + /// /Creates a new instance of with a specified name. + /// + /// The name of the wind direction + /// A which can be readily used for testing. + /// Thrown when + /// is null. + public static WindDirection CreateTestWindDirection(string name) + { + return new WindDirection(name, 5.0); + } } } \ No newline at end of file Index: Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/TopLevelSubMechanismIllustrationPointPropertiesTest.cs =================================================================== diff -u -r3fbb377f0b3df239bfe408f55f45bb67eb5440a2 -r47ffe2caa64a35b18c61dfef4b795ab0f0f30bc1 --- Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/TopLevelSubMechanismIllustrationPointPropertiesTest.cs (.../TopLevelSubMechanismIllustrationPointPropertiesTest.cs) (revision 3fbb377f0b3df239bfe408f55f45bb67eb5440a2) +++ Ringtoets/Common/test/Ringtoets.Common.Forms.Test/PropertyClasses/TopLevelSubMechanismIllustrationPointPropertiesTest.cs (.../TopLevelSubMechanismIllustrationPointPropertiesTest.cs) (revision 47ffe2caa64a35b18c61dfef4b795ab0f0f30bc1) @@ -142,6 +142,44 @@ } [Test] + public void GetProperties_ValidData_ReturnsExpectedValues() + { + var random = new Random(21); + double beta = random.NextDouble(); + var stochasts = new[] + { + new SubMechanismIllustrationPointStochast("some name", random.NextDouble(), random.NextDouble(), random.NextDouble()) + }; + var illustrationPointResults = new[] + { + new IllustrationPointResult("some description", random.NextDouble()) + }; + + const string illustrationPointName = "name"; + var submechanismIllustrationPoint = new SubMechanismIllustrationPoint(illustrationPointName, + beta, + stochasts, + illustrationPointResults); + + const string closingSituation = "closingSituation"; + const string windDirectionName = "windDirection"; + var context = new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(windDirectionName), + closingSituation, + submechanismIllustrationPoint); + + // Call + var properties = new TopLevelSubMechanismIllustrationPointProperties(context, Enumerable.Empty()); + + // Assert + Assert.AreEqual(illustrationPointName, properties.Name); + Assert.AreEqual(windDirectionName, properties.WindDirection); + Assert.AreEqual(closingSituation, properties.ClosingSituation); + CollectionAssert.AreEqual(submechanismIllustrationPoint.Stochasts, properties.AlphaValues); + CollectionAssert.AreEqual(submechanismIllustrationPoint.Stochasts, properties.Durations); + CollectionAssert.AreEqual(submechanismIllustrationPoint.IllustrationPointResults, properties.IllustrationPointResults); + } + + [Test] public void GetProperties_DifferentClosingSituations_ReturnsExpectedAttributeValues() { // Setup @@ -228,43 +266,17 @@ } [Test] - public void GetProperties_ValidData_ReturnsExpectedValues() + public void GetProperties_ValidData_ReturnsExpectedAttributeValues() { // Setup - var random = new Random(21); - double beta = random.NextDouble(); - var stochasts = new[] - { - new SubMechanismIllustrationPointStochast("some name", random.NextDouble(), random.NextDouble(), random.NextDouble()) - }; - var illustrationPointResults = new[] - { - new IllustrationPointResult("some description", random.NextDouble()) - }; + var context = new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection(), + "closingSituation", + new TestSubMechanismIllustrationPoint()); - const string illustrationPointName = "name"; - var submechanismIllustrationPoint = new SubMechanismIllustrationPoint(illustrationPointName, - beta, - stochasts, - illustrationPointResults); - - const string closingSituation = "closingSituation"; - const string windDirectionName = "windDirection"; - var windDirection = new WindDirection(windDirectionName, 123); - - var context = new TopLevelSubMechanismIllustrationPoint(windDirection, closingSituation, submechanismIllustrationPoint); - // Call var properties = new TopLevelSubMechanismIllustrationPointProperties(context, Enumerable.Empty()); // Assert - Assert.AreEqual(illustrationPointName, properties.Name); - Assert.AreEqual(windDirectionName, properties.WindDirection); - Assert.AreEqual(closingSituation, properties.ClosingSituation); - CollectionAssert.AreEqual(submechanismIllustrationPoint.Stochasts, properties.AlphaValues); - CollectionAssert.AreEqual(submechanismIllustrationPoint.Stochasts, properties.Durations); - CollectionAssert.AreEqual(submechanismIllustrationPoint.IllustrationPointResults, properties.IllustrationPointResults); - TypeConverter classTypeConverter = TypeDescriptor.GetConverter(properties, true); Assert.IsInstanceOf(classTypeConverter); Index: Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsHydraulicBoundaryLocationContextPropertiesTest.cs =================================================================== diff -u -rb20450e554f48304ee71ee7ebc20885257118ee6 -r47ffe2caa64a35b18c61dfef4b795ab0f0f30bc1 --- Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsHydraulicBoundaryLocationContextPropertiesTest.cs (.../GrassCoverErosionOutwardsHydraulicBoundaryLocationContextPropertiesTest.cs) (revision b20450e554f48304ee71ee7ebc20885257118ee6) +++ Ringtoets/GrassCoverErosionOutwards/test/Ringtoets.GrassCoverErosionOutwards.Forms.Test/PropertyClasses/GrassCoverErosionOutwardsHydraulicBoundaryLocationContextPropertiesTest.cs (.../GrassCoverErosionOutwardsHydraulicBoundaryLocationContextPropertiesTest.cs) (revision 47ffe2caa64a35b18c61dfef4b795ab0f0f30bc1) @@ -118,22 +118,22 @@ var context = new TestGrassCoverErosionOutwardsLocationContext(locations, hydraulicBoundaryLocation); var random = new Random(21); - var windDirection = new WindDirection("WindDirection name", random.NextDouble()); - var topLevelIllustrationPoint = new TopLevelSubMechanismIllustrationPoint(windDirection, - "closing situation", - new TestSubMechanismIllustrationPoint()); + var topLevelIllustrationPoint = + new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection("Wind Direction Name"), + "closing situation", + new TestSubMechanismIllustrationPoint()); var stochast = new Stochast("stochastName", random.NextDouble(), random.NextDouble()); - var governingWindDirection = new WindDirection("Governing WindDirectionName", random.NextDouble()); - var generalResult = new GeneralResult(governingWindDirection, new[] - { - stochast - }, new[] - { - topLevelIllustrationPoint - }); + var generalResult = new GeneralResult( + WindDirectionTestFactory.CreateTestWindDirection("Governing wind Direction name"), new[] + { + stochast + }, new[] + { + topLevelIllustrationPoint + }); // Call var locationProperties = new TestGrassCoverErosionOutwardsLocationProperties @@ -147,14 +147,11 @@ Assert.AreEqual(name, locationProperties.Name); var coordinates = new Point2D(x, y); Assert.AreEqual(coordinates, locationProperties.Location); - Assert.AreEqual(governingWindDirection.Name, locationProperties.GoverningWindDirection); - Stochast actualAlphaValue = locationProperties.AlphaValues.Single(); - AssertStochast(stochast, actualAlphaValue); + Assert.AreEqual(generalResult.GoverningWindDirection.Name, locationProperties.GoverningWindDirection); + CollectionAssert.AreEqual(generalResult.Stochasts, locationProperties.AlphaValues); + CollectionAssert.AreEqual(generalResult.Stochasts, locationProperties.Durations); - Stochast actualDuration = locationProperties.Durations.Single(); - AssertStochast(stochast, actualDuration); - TopLevelSubMechanismIllustrationPointProperties topLevelProperties = locationProperties.IllustrationPoints.Single(); Assert.AreEqual(topLevelIllustrationPoint.SubMechanismIllustrationPoint.Name, topLevelProperties.Name); Index: Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryLocationPropertiesTest.cs =================================================================== diff -u -rb20450e554f48304ee71ee7ebc20885257118ee6 -r47ffe2caa64a35b18c61dfef4b795ab0f0f30bc1 --- Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryLocationPropertiesTest.cs (.../HydraulicBoundaryLocationPropertiesTest.cs) (revision b20450e554f48304ee71ee7ebc20885257118ee6) +++ Ringtoets/Integration/test/Ringtoets.Integration.Forms.Test/PropertyClasses/HydraulicBoundaryLocationPropertiesTest.cs (.../HydraulicBoundaryLocationPropertiesTest.cs) (revision 47ffe2caa64a35b18c61dfef4b795ab0f0f30bc1) @@ -100,22 +100,22 @@ var context = new TestHydraulicBoundaryLocationContext(hydraulicBoundaryDatabase, hydraulicBoundaryLocation); var random = new Random(21); - var windDirection = new WindDirection("WindDirection name", random.NextDouble()); - var topLevelIllustrationPoint = new TopLevelSubMechanismIllustrationPoint(windDirection, - "closing situation", - new TestSubMechanismIllustrationPoint()); + var topLevelIllustrationPoint = + new TopLevelSubMechanismIllustrationPoint(WindDirectionTestFactory.CreateTestWindDirection("Wind direction name"), + "closing situation", + new TestSubMechanismIllustrationPoint()); var stochast = new Stochast("stochastName", random.NextDouble(), random.NextDouble()); - var governingWindDirection = new WindDirection("Governing WindDirectionName", random.NextDouble()); - var generalResult = new GeneralResult(governingWindDirection, new[] - { - stochast - }, new[] - { - topLevelIllustrationPoint - }); + var generalResult = new GeneralResult( + WindDirectionTestFactory.CreateTestWindDirection("Governing Wind Direction Name"), new[] + { + stochast + }, new[] + { + topLevelIllustrationPoint + }); // Call var locationProperties = new TestHydraulicBoundaryLocationProperties @@ -129,14 +129,11 @@ Assert.AreEqual(name, locationProperties.Name); var coordinates = new Point2D(x, y); Assert.AreEqual(coordinates, locationProperties.Location); - Assert.AreEqual(governingWindDirection.Name, locationProperties.GoverningWindDirection); - Stochast actualAlphaValue = locationProperties.AlphaValues.Single(); - AssertStochast(stochast, actualAlphaValue); + Assert.AreEqual(generalResult.GoverningWindDirection.Name, locationProperties.GoverningWindDirection); + CollectionAssert.AreEqual(generalResult.Stochasts, locationProperties.AlphaValues); + CollectionAssert.AreEqual(generalResult.Stochasts, locationProperties.Durations); - Stochast actualDuration = locationProperties.Durations.Single(); - AssertStochast(stochast, actualDuration); - TopLevelSubMechanismIllustrationPointProperties topLevelProperties = locationProperties.IllustrationPoints.Single(); Assert.AreEqual(topLevelIllustrationPoint.SubMechanismIllustrationPoint.Name, topLevelProperties.Name);