Index: Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StructuresCalculationCreateExtensionsTest.cs =================================================================== diff -u -r659839900c53f9f65ffe8c811e0cb876de55398f -r699aed8b7cadb16fa905b2e54c8174d0d5747b99 --- Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StructuresCalculationCreateExtensionsTest.cs (.../StructuresCalculationCreateExtensionsTest.cs) (revision 659839900c53f9f65ffe8c811e0cb876de55398f) +++ Application/Ringtoets/test/Application.Ringtoets.Storage.Test/Create/StructuresCalculationCreateExtensionsTest.cs (.../StructuresCalculationCreateExtensionsTest.cs) (revision 699aed8b7cadb16fa905b2e54c8174d0d5747b99) @@ -31,6 +31,7 @@ using Ringtoets.Common.Data.DikeProfiles; using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.IllustrationPoints; +using Ringtoets.Common.Data.Probability; using Ringtoets.Common.Data.Structures; using Ringtoets.Common.Data.TestUtil; using Ringtoets.Common.Data.TestUtil.IllustrationPoints; @@ -44,29 +45,17 @@ [TestFixture] public class StructuresCalculationCreateExtensionsTest { - private static StructuresOutput GetStructuresOutputWithGeneralResult() + private static void AssertStructuresOutputEntity(StructuresOutput output, T outputEntity) + where T : IHasGeneralResultFaultTreeIllustrationPointEntity, IProbabilityAssessmentOutputEntity { - return new TestStructuresOutput(new TestGeneralResultFaultTreeIllustrationPoint()); - } + ProbabilityAssessmentOutput expectedProbabilityAssessmentOutput = output.ProbabilityAssessmentOutput; + Assert.AreEqual(expectedProbabilityAssessmentOutput.RequiredProbability, outputEntity.RequiredProbability); + Assert.AreEqual(expectedProbabilityAssessmentOutput.RequiredReliability, outputEntity.RequiredReliability); + Assert.AreEqual(expectedProbabilityAssessmentOutput.Probability, outputEntity.Probability); + Assert.AreEqual(expectedProbabilityAssessmentOutput.Reliability, outputEntity.Reliability); + Assert.AreEqual(expectedProbabilityAssessmentOutput.FactorOfSafety, outputEntity.FactorOfSafety); - private static void AssertGeneralResult(GeneralResult illustrationPoint, - GeneralResultFaultTreeIllustrationPointEntity entity) - { - if (illustrationPoint == null) - { - Assert.IsNull(entity); - return; - } - - Assert.IsNotNull(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.TopLevelIllustrationPoints.Count(), - entity.TopLevelFaultTreeIllustrationPointEntities.Count); + Assert.IsNull(outputEntity.GeneralResultFaultTreeIllustrationPointEntity); } #region CreateForHeightStructures @@ -369,33 +358,9 @@ HeightStructuresCalculationEntity entity = calculation.CreateForHeightStructures(registry, 0); // Assert - Assert.AreEqual(1, entity.HeightStructuresOutputEntities.Count); + AssertStructuresOutputEntity(calculation.Output, entity.HeightStructuresOutputEntities.Single()); } - [Test] - public void CreateForHeightStructures_CalculationWithOutputAndGeneralResult_ReturnEntityWithOutputAndGeneralResult() - { - // Setup - StructuresOutput output = GetStructuresOutputWithGeneralResult(); - var calculation = new StructuresCalculation - { - Output = output - }; - - var registry = new PersistenceRegistry(); - - // Call - HeightStructuresCalculationEntity entity = calculation.CreateForHeightStructures(registry, 0); - - // Assert - HeightStructuresOutputEntity outputEntity = entity.HeightStructuresOutputEntities.Single(); - Assert.IsNotNull(outputEntity); - GeneralResultFaultTreeIllustrationPointEntity generalResultEntity = outputEntity.GeneralResultFaultTreeIllustrationPointEntity; - Assert.IsNotNull(generalResultEntity); - - AssertGeneralResult(output.GeneralResult, generalResultEntity); - } - #endregion #region CreateForClosingStructures @@ -754,33 +719,9 @@ ClosingStructuresCalculationEntity entity = calculation.CreateForClosingStructures(registry, 0); // Assert - Assert.AreEqual(1, entity.ClosingStructuresOutputEntities.Count); + AssertStructuresOutputEntity(calculation.Output, entity.ClosingStructuresOutputEntities.Single()); } - [Test] - public void CreateForClosingStructures_CalculationWithOutputAndGeneralResult_ReturnEntityWithOutputAndGeneralResult() - { - // Setup - StructuresOutput output = GetStructuresOutputWithGeneralResult(); - var calculation = new StructuresCalculation - { - Output = output - }; - - var registry = new PersistenceRegistry(); - - // Call - ClosingStructuresCalculationEntity entity = calculation.CreateForClosingStructures(registry, 0); - - // Assert - ClosingStructuresOutputEntity outputEntity = entity.ClosingStructuresOutputEntities.Single(); - Assert.IsNotNull(outputEntity); - GeneralResultFaultTreeIllustrationPointEntity generalResultEntity = outputEntity.GeneralResultFaultTreeIllustrationPointEntity; - Assert.IsNotNull(generalResultEntity); - - AssertGeneralResult(output.GeneralResult, generalResultEntity); - } - #endregion #region CreateForStabilityPointStructures @@ -1288,33 +1229,9 @@ StabilityPointStructuresCalculationEntity entity = calculation.CreateForStabilityPointStructures(registry, 0); // Assert - Assert.AreEqual(1, entity.StabilityPointStructuresOutputEntities.Count); + AssertStructuresOutputEntity(calculation.Output, entity.StabilityPointStructuresOutputEntities.Single()); } - [Test] - public void CreateForStabilityPointStructures_CalculationWithOutputAndGeneralResult_ReturnEntityWithOutputAndGeneralResult() - { - // Setup - StructuresOutput output = GetStructuresOutputWithGeneralResult(); - var calculation = new StructuresCalculation - { - Output = output - }; - - var registry = new PersistenceRegistry(); - - // Call - StabilityPointStructuresCalculationEntity entity = calculation.CreateForStabilityPointStructures(registry, 0); - - // Assert - StabilityPointStructuresOutputEntity outputEntity = entity.StabilityPointStructuresOutputEntities.Single(); - Assert.IsNotNull(outputEntity); - GeneralResultFaultTreeIllustrationPointEntity generalResultEntity = outputEntity.GeneralResultFaultTreeIllustrationPointEntity; - Assert.IsNotNull(generalResultEntity); - - AssertGeneralResult(output.GeneralResult, generalResultEntity); - } - #endregion } } \ No newline at end of file