Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HydraulicBoundaryLocationCreateExtensionsTest.cs =================================================================== diff -u -r14a04f6f5ad2079a2dbf88db0b762a203edb82af -r5b6acfd4bce67d0c0969ad4e6e3df0bd801d6632 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HydraulicBoundaryLocationCreateExtensionsTest.cs (.../HydraulicBoundaryLocationCreateExtensionsTest.cs) (revision 14a04f6f5ad2079a2dbf88db0b762a203edb82af) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/HydraulicBoundaryLocationCreateExtensionsTest.cs (.../HydraulicBoundaryLocationCreateExtensionsTest.cs) (revision 5b6acfd4bce67d0c0969ad4e6e3df0bd801d6632) @@ -26,7 +26,9 @@ using Core.Common.TestUtil; using NUnit.Framework; using Ringtoets.Common.Data.Hydraulics; +using Ringtoets.Common.Data.Hydraulics.IllustrationPoints; using Ringtoets.Common.Data.TestUtil; +using Ringtoets.Common.Data.TestUtil.IllustrationPoints; namespace Application.Ringtoets.Storage.Test.Create { @@ -148,13 +150,73 @@ IHydraulicLocationOutputEntity designWaterLevelOutputEntity = GetHydraulicLocationOutputEntity(entity, HydraulicLocationOutputType.DesignWaterLevel); Assert.IsNotNull(designWaterLevelOutputEntity); AssertHydraulicBoundaryLocationOutput(hydraulicBoundaryLocationDesignWaterLevelOutput, designWaterLevelOutputEntity); + Assert.IsNull(designWaterLevelOutputEntity.GeneralResultSubMechanismIllustrationPointEntity); IHydraulicLocationOutputEntity waveheightOutputEntity = GetHydraulicLocationOutputEntity(entity, HydraulicLocationOutputType.DesignWaterLevel); Assert.IsNotNull(waveheightOutputEntity); AssertHydraulicBoundaryLocationOutput(hydraulicBoundaryLocationDesignWaterLevelOutput, waveheightOutputEntity); + Assert.IsNull(waveheightOutputEntity.GeneralResultSubMechanismIllustrationPointEntity); } [Test] + public void Create_WithPersistenceRegistryAndIllustrationPoints_ReturnsHydraulicLocationEntityWithOutputAndIllustrationPointsSet() + { + // Setup + var random = new Random(21); + var hydraulicBoundaryLocationDesignWaterLevelOutput = new HydraulicBoundaryLocationOutput( + random.NextDouble(), random.NextDouble(), random.NextDouble(), random.NextDouble(), + random.NextDouble(), random.NextEnumValue()); + hydraulicBoundaryLocationDesignWaterLevelOutput.SetIllustrationPoints(new TestGeneralResultSubMechanismIllustrationPoint()); + + var hydraulicBoundaryLocationWaveHeightOutput = new HydraulicBoundaryLocationOutput( + random.NextDouble(), random.NextDouble(), random.NextDouble(), random.NextDouble(), + random.NextDouble(), random.NextEnumValue()); + hydraulicBoundaryLocationWaveHeightOutput.SetIllustrationPoints(new TestGeneralResultSubMechanismIllustrationPoint()); + + bool shouldIllustrationPointsBeCalculated = random.NextBoolean(); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(-1, "testName", random.NextDouble(), random.NextDouble()) + { + DesignWaterLevelCalculation = + { + InputParameters = + { + ShouldIllustrationPointsBeCalculated = shouldIllustrationPointsBeCalculated + }, + Output = hydraulicBoundaryLocationDesignWaterLevelOutput + }, + WaveHeightCalculation = + { + InputParameters = + { + ShouldIllustrationPointsBeCalculated = shouldIllustrationPointsBeCalculated + }, + Output = hydraulicBoundaryLocationWaveHeightOutput + } + }; + var registry = new PersistenceRegistry(); + + // Call + HydraulicLocationEntity entity = hydraulicBoundaryLocation.Create(registry, 0); + + // Assert + Assert.IsNotNull(entity); + + IHydraulicLocationOutputEntity designWaterLevelOutputEntity = GetHydraulicLocationOutputEntity(entity, HydraulicLocationOutputType.DesignWaterLevel); + Assert.IsNotNull(designWaterLevelOutputEntity); + AssertHydraulicBoundaryLocationOutput(hydraulicBoundaryLocationDesignWaterLevelOutput, designWaterLevelOutputEntity); + Assert.IsNotNull(designWaterLevelOutputEntity.GeneralResultSubMechanismIllustrationPointEntity); + AssertGeneralResultSubMechanismIllustrationPoint(hydraulicBoundaryLocationDesignWaterLevelOutput.GeneralResultSubMechanismIllustrationPoint, + designWaterLevelOutputEntity.GeneralResultSubMechanismIllustrationPointEntity); + + IHydraulicLocationOutputEntity waveheightOutputEntity = GetHydraulicLocationOutputEntity(entity, HydraulicLocationOutputType.DesignWaterLevel); + Assert.IsNotNull(waveheightOutputEntity); + AssertHydraulicBoundaryLocationOutput(hydraulicBoundaryLocationDesignWaterLevelOutput, waveheightOutputEntity); + Assert.IsNotNull(waveheightOutputEntity.GeneralResultSubMechanismIllustrationPointEntity); + AssertGeneralResultSubMechanismIllustrationPoint(hydraulicBoundaryLocationWaveHeightOutput.GeneralResultSubMechanismIllustrationPoint, + waveheightOutputEntity.GeneralResultSubMechanismIllustrationPointEntity); + } + + [Test] public void Create_HydraulicBoundaryLocationSavedMultipleTimes_ReturnSameEntity() { // Setup @@ -285,13 +347,73 @@ IHydraulicLocationOutputEntity designWaterLevelOutputEntity = GetHydraulicLocationOutputEntity(entity, HydraulicLocationOutputType.DesignWaterLevel); Assert.IsNotNull(designWaterLevelOutputEntity); AssertHydraulicBoundaryLocationOutput(hydraulicBoundaryLocationDesignWaterLevelOutput, designWaterLevelOutputEntity); + Assert.IsNull(designWaterLevelOutputEntity.GeneralResultSubMechanismIllustrationPointEntity); IHydraulicLocationOutputEntity waveheightOutputEntity = GetHydraulicLocationOutputEntity(entity, HydraulicLocationOutputType.DesignWaterLevel); Assert.IsNotNull(waveheightOutputEntity); AssertHydraulicBoundaryLocationOutput(hydraulicBoundaryLocationDesignWaterLevelOutput, waveheightOutputEntity); + Assert.IsNull(waveheightOutputEntity.GeneralResultSubMechanismIllustrationPointEntity); } [Test] + public void CreateGrassCoverErosionOutwardsHydraulicBoundaryLocation_WithPersistenceRegistryAndIllustrationPoints_ReturnsGrassCoverErosionOutwardsHydraulicLocationEntityWithOutputAndIllustrationPointsSet() + { + // Setup + var random = new Random(21); + var hydraulicBoundaryLocationDesignWaterLevelOutput = new HydraulicBoundaryLocationOutput( + random.NextDouble(), random.NextDouble(), random.NextDouble(), random.NextDouble(), + random.NextDouble(), random.NextEnumValue()); + hydraulicBoundaryLocationDesignWaterLevelOutput.SetIllustrationPoints(new TestGeneralResultSubMechanismIllustrationPoint()); + + var hydraulicBoundaryLocationWaveHeightOutput = new HydraulicBoundaryLocationOutput( + random.NextDouble(), random.NextDouble(), random.NextDouble(), random.NextDouble(), + random.NextDouble(), random.NextEnumValue()); + hydraulicBoundaryLocationWaveHeightOutput.SetIllustrationPoints(new TestGeneralResultSubMechanismIllustrationPoint()); + + bool shouldIllustrationPointsBeCalculated = random.NextBoolean(); + var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(-1, "testName", random.NextDouble(), random.NextDouble()) + { + DesignWaterLevelCalculation = + { + InputParameters = + { + ShouldIllustrationPointsBeCalculated = shouldIllustrationPointsBeCalculated + }, + Output = hydraulicBoundaryLocationDesignWaterLevelOutput + }, + WaveHeightCalculation = + { + InputParameters = + { + ShouldIllustrationPointsBeCalculated = shouldIllustrationPointsBeCalculated + }, + Output = hydraulicBoundaryLocationWaveHeightOutput + } + }; + var registry = new PersistenceRegistry(); + + // Call + GrassCoverErosionOutwardsHydraulicLocationEntity entity = + hydraulicBoundaryLocation.CreateGrassCoverErosionOutwardsHydraulicBoundaryLocation(registry, 0); + + // Assert + Assert.IsNotNull(entity); + IHydraulicLocationOutputEntity designWaterLevelOutputEntity = GetHydraulicLocationOutputEntity(entity, HydraulicLocationOutputType.DesignWaterLevel); + Assert.IsNotNull(designWaterLevelOutputEntity); + AssertHydraulicBoundaryLocationOutput(hydraulicBoundaryLocationDesignWaterLevelOutput, designWaterLevelOutputEntity); + Assert.IsNotNull(designWaterLevelOutputEntity.GeneralResultSubMechanismIllustrationPointEntity); + AssertGeneralResultSubMechanismIllustrationPoint(hydraulicBoundaryLocationWaveHeightOutput.GeneralResultSubMechanismIllustrationPoint, + designWaterLevelOutputEntity.GeneralResultSubMechanismIllustrationPointEntity); + + IHydraulicLocationOutputEntity waveheightOutputEntity = GetHydraulicLocationOutputEntity(entity, HydraulicLocationOutputType.DesignWaterLevel); + Assert.IsNotNull(waveheightOutputEntity); + AssertHydraulicBoundaryLocationOutput(hydraulicBoundaryLocationDesignWaterLevelOutput, waveheightOutputEntity); + Assert.IsNotNull(waveheightOutputEntity.GeneralResultSubMechanismIllustrationPointEntity); + AssertGeneralResultSubMechanismIllustrationPoint(hydraulicBoundaryLocationWaveHeightOutput.GeneralResultSubMechanismIllustrationPoint, + waveheightOutputEntity.GeneralResultSubMechanismIllustrationPointEntity); + } + + [Test] public void CreateGrassCoverErosionOutwardsHydraulicBoundaryLocation_HydraulicBoundaryLocationSavedMultipleTimes_ReturnSameEntity() { // Setup @@ -332,5 +454,18 @@ Assert.AreEqual(output.CalculatedReliability, entity.CalculatedReliability, output.CalculatedReliability.GetAccuracy()); Assert.AreEqual(output.CalculationConvergence, (CalculationConvergence) entity.CalculationConvergence); } + + private static void AssertGeneralResultSubMechanismIllustrationPoint(GeneralResultSubMechanismIllustrationPoint illustrationPoint, + GeneralResultSubMechanismIllustrationPointEntity entity) + { + WindDirection governingWindDirection = illustrationPoint.GoverningWindDirection; + TestHelper.AssertAreEqualButNotSame(governingWindDirection.Name, entity.GoverningWindDirectionName); + Assert.AreEqual(governingWindDirection.Angle, entity.GoverningWindDirectionAngle, + governingWindDirection.Angle.GetAccuracy()); + + Assert.AreEqual(illustrationPoint.Stochasts.Count(), entity.StochastEntities.Count); + Assert.AreEqual(illustrationPoint.TopLevelSubMechanismIllustrationPoints.Count(), + entity.TopLevelSubMechanismIllustrationPointEntities.Count); + } } } \ No newline at end of file