Index: Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/PropertyInfos/StabilityStoneCoverWaveConditionsInputContextPropertyInfoTest.cs =================================================================== diff -u -r6f33b44599df032ecae3342b0aacd606a9e87c1f -re7e455ded8ce63d7d6694009d2b6d71d6e233bdf --- Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/PropertyInfos/StabilityStoneCoverWaveConditionsInputContextPropertyInfoTest.cs (.../StabilityStoneCoverWaveConditionsInputContextPropertyInfoTest.cs) (revision 6f33b44599df032ecae3342b0aacd606a9e87c1f) +++ Ringtoets/StabilityStoneCover/test/Ringtoets.StabilityStoneCover.Plugin.Test/PropertyInfos/StabilityStoneCoverWaveConditionsInputContextPropertyInfoTest.cs (.../StabilityStoneCoverWaveConditionsInputContextPropertyInfoTest.cs) (revision e7e455ded8ce63d7d6694009d2b6d71d6e233bdf) @@ -19,12 +19,15 @@ // Stichting Deltares and remain full property of Stichting Deltares at all times. // All rights reserved. +using System.Collections; using System.Linq; +using Core.Common.Base.Data; using Core.Common.Gui.Plugin; using Core.Common.Gui.PropertyBag; using NUnit.Framework; -using Ringtoets.Common.Data.Contribution; +using Ringtoets.Common.Data.AssessmentSection; using Ringtoets.Common.Data.DikeProfiles; +using Ringtoets.Common.Data.Hydraulics; using Ringtoets.Common.Data.TestUtil; using Ringtoets.StabilityStoneCover.Data; using Ringtoets.StabilityStoneCover.Forms.PresentationObjects; @@ -51,23 +54,20 @@ } [Test] - public void CreateInstance_WithContextAndNormTypeSignaling_ExpectedProperties() + [TestCaseSource(nameof(DifferentCategoryTypes))] + public void CreateInstance_WithContextThatHasInputWithSpecificCategoryType_ExpectedProperties( + IAssessmentSection assessmentSection, + HydraulicBoundaryLocation hydraulicBoundaryLocation, + AssessmentSectionCategoryType categoryType, + RoundedDouble expectedAssessmentLevel) { // Setup - var assessmentSection = new AssessmentSectionStub - { - FailureMechanismContribution = - { - NormativeNorm = NormType.Signaling - } - }; - - var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); var calculation = new StabilityStoneCoverWaveConditionsCalculation { InputParameters = { - HydraulicBoundaryLocation = hydraulicBoundaryLocation + HydraulicBoundaryLocation = hydraulicBoundaryLocation, + CategoryType = categoryType } }; @@ -76,11 +76,6 @@ assessmentSection, new ForeshoreProfile[0]); - assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] - { - hydraulicBoundaryLocation - }, true); - using (var plugin = new StabilityStoneCoverPlugin()) { PropertyInfo info = GetInfo(plugin); @@ -92,61 +87,52 @@ Assert.IsInstanceOf(objectProperties); Assert.AreSame(context, objectProperties.Data); - double expectedAssessmentLevel = assessmentSection.WaterLevelCalculationsForSignalingNorm.ElementAt(0).Output.Result; Assert.AreEqual(expectedAssessmentLevel, ((StabilityStoneCoverWaveConditionsInputContextProperties) objectProperties).AssessmentLevel); } } - [Test] - public void CreateInstance_WithContextAndNormTypeLowerLimit_ExpectedProperties() + private static PropertyInfo GetInfo(StabilityStoneCoverPlugin plugin) { - // Setup - var assessmentSection = new AssessmentSectionStub - { - FailureMechanismContribution = - { - NormativeNorm = NormType.LowerLimit - } - }; + return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(StabilityStoneCoverWaveConditionsInputContext)); + } + private static IEnumerable DifferentCategoryTypes() + { + var assessmentSection = new AssessmentSectionStub(); var hydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(); - var calculation = new StabilityStoneCoverWaveConditionsCalculation - { - InputParameters = - { - HydraulicBoundaryLocation = hydraulicBoundaryLocation - } - }; - var context = new StabilityStoneCoverWaveConditionsInputContext(calculation.InputParameters, - calculation, - assessmentSection, - new ForeshoreProfile[0]); - assessmentSection.SetHydraulicBoundaryLocationCalculations(new[] { hydraulicBoundaryLocation }, true); - using (var plugin = new StabilityStoneCoverPlugin()) - { - PropertyInfo info = GetInfo(plugin); + yield return new TestCaseData( + assessmentSection, + hydraulicBoundaryLocation, + AssessmentSectionCategoryType.FactorizedSignalingNorm, + assessmentSection.WaterLevelCalculationsForFactorizedSignalingNorm.ElementAt(0).Output.Result + ).SetName("FactorizedSignalingNorm"); - // Call - IObjectProperties objectProperties = info.CreateInstance(context); + yield return new TestCaseData( + assessmentSection, + hydraulicBoundaryLocation, + AssessmentSectionCategoryType.SignalingNorm, + assessmentSection.WaterLevelCalculationsForSignalingNorm.ElementAt(0).Output.Result + ).SetName("SignalingNorm"); - // Assert - Assert.IsInstanceOf(objectProperties); - Assert.AreSame(context, objectProperties.Data); + yield return new TestCaseData( + assessmentSection, + hydraulicBoundaryLocation, + AssessmentSectionCategoryType.LowerLimitNorm, + assessmentSection.WaterLevelCalculationsForLowerLimitNorm.ElementAt(0).Output.Result + ).SetName("LowerLimitNorm"); - double expectedAssessmentLevel = assessmentSection.WaterLevelCalculationsForLowerLimitNorm.ElementAt(0).Output.Result; - Assert.AreEqual(expectedAssessmentLevel, ((StabilityStoneCoverWaveConditionsInputContextProperties) objectProperties).AssessmentLevel); - } + yield return new TestCaseData( + assessmentSection, + hydraulicBoundaryLocation, + AssessmentSectionCategoryType.FactorizedLowerLimitNorm, + assessmentSection.WaterLevelCalculationsForFactorizedLowerLimitNorm.ElementAt(0).Output.Result + ).SetName("FactorizedLowerLimitNorm"); } - - private static PropertyInfo GetInfo(StabilityStoneCoverPlugin plugin) - { - return plugin.GetPropertyInfos().First(pi => pi.DataType == typeof(StabilityStoneCoverWaveConditionsInputContext)); - } } } \ No newline at end of file