Index: Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/Configurations/HeightStructuresCalculationStochastAssignerTest.cs =================================================================== diff -u -r65c74eaad22b576971bae588c9793d76950b8cad -r0bae0773243658d37a619b2904879e11c6aebe82 --- Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/Configurations/HeightStructuresCalculationStochastAssignerTest.cs (.../HeightStructuresCalculationStochastAssignerTest.cs) (revision 65c74eaad22b576971bae588c9793d76950b8cad) +++ Ringtoets/HeightStructures/test/Ringtoets.HeightStructures.IO.Test/Configurations/HeightStructuresCalculationStochastAssignerTest.cs (.../HeightStructuresCalculationStochastAssignerTest.cs) (revision 0bae0773243658d37a619b2904879e11c6aebe82) @@ -32,69 +32,6 @@ [TestFixture] public class HeightStructuresCalculationStochastAssignerTest { - private static IEnumerable GetSetStochastParametersActions(string testNameFormat) - { - foreach (TestCaseData caseData in StochastConfigurationCases((c, s) => c.LevelCrestStructure = s, "LevelCrest", testNameFormat, true)) - { - yield return caseData; - } - foreach (TestCaseData caseData in StochastConfigurationCases((c, s) => c.AllowedLevelIncreaseStorage = s, "AllowedLevelIncreaseStorage", testNameFormat, true)) - { - yield return caseData; - } - foreach (TestCaseData caseData in StochastConfigurationCases((c, s) => c.FlowWidthAtBottomProtection = s, "FlowWidthAtBottomProtection", testNameFormat, true)) - { - yield return caseData; - } - foreach (TestCaseData caseData in StochastConfigurationCases((c, s) => c.WidthFlowApertures = s, "WidthFlowApertures", testNameFormat, true)) - { - yield return caseData; - } - foreach (TestCaseData caseData in StochastConfigurationCases((c, s) => c.CriticalOvertoppingDischarge = s, "CriticalOvertoppingDischarge", testNameFormat, false)) - { - yield return caseData; - } - foreach (TestCaseData caseData in StochastConfigurationCases((c, s) => c.StorageStructureArea = s, "StorageStructureArea", testNameFormat, false)) - { - yield return caseData; - } - } - - private static IEnumerable StochastConfigurationCases( - Action modifyStochastAction, - string stochastName, - string testNameFormat, - bool standardDeviation) - { - var random = new Random(21); - - yield return new TestCaseData( - new Action(c => modifyStochastAction(c, new StochastConfiguration - { - Mean = random.NextDouble() - }))) - .SetName(string.Format(testNameFormat, $"{stochastName}Mean")); - - if (standardDeviation) - { - yield return new TestCaseData( - new Action(c => modifyStochastAction(c, new StochastConfiguration - { - StandardDeviation = random.NextDouble() - }))) - .SetName(string.Format(testNameFormat, $"{stochastName}StandardDeviation")); - } - else - { - yield return new TestCaseData( - new Action(c => modifyStochastAction(c, new StochastConfiguration - { - VariationCoefficient = random.NextDouble() - }))) - .SetName(string.Format(testNameFormat, $"{stochastName}VariationCoefficient")); - } - } - [Test] public void Constructor_WithParameters_ReturnsNewInstance() { @@ -108,8 +45,8 @@ calculation); // Assert - Assert.IsInstanceOf>(assigner); } @@ -135,7 +72,7 @@ calculation); // Call - var valid = assigner.Assign(); + bool valid = assigner.Assign(); // Assert Assert.IsFalse(valid); @@ -166,7 +103,7 @@ calculation); // Call - var valid = assigner.Assign(); + bool valid = assigner.Assign(); // Assert Assert.IsTrue(valid); @@ -176,16 +113,14 @@ public void SetStochasts_WithAllStochastsSet_SetExpectedValuesOnInput() { // Setup - var levelCrestStructure = new StochastConfiguration - { - Mean = 1.1, - StandardDeviation = 1.5 - }; - var configuration = new HeightStructuresCalculationConfiguration("name") { StructureName = "some structure", - LevelCrestStructure = levelCrestStructure, + LevelCrestStructure = new StochastConfiguration + { + Mean = 1.1, + StandardDeviation = 1.5 + }, AllowedLevelIncreaseStorage = new StochastConfiguration { Mean = 2.1, @@ -228,10 +163,97 @@ calculation); // Call - var valid = assigner.Assign(); + bool valid = assigner.Assign(); // Assert Assert.IsTrue(valid); } + + private static IEnumerable GetSetStochastParametersActions(string testNameFormat) + { + foreach (TestCaseData caseData in StochastConfigurationCases( + (c, s) => c.LevelCrestStructure = s, + nameof(HeightStructuresCalculationConfiguration.LevelCrestStructure), + testNameFormat, + true)) + { + yield return caseData; + } + foreach (TestCaseData caseData in StochastConfigurationCases( + (c, s) => c.AllowedLevelIncreaseStorage = s, + nameof(HeightStructuresCalculationConfiguration.AllowedLevelIncreaseStorage), + testNameFormat, + true)) + { + yield return caseData; + } + foreach (TestCaseData caseData in StochastConfigurationCases( + (c, s) => c.FlowWidthAtBottomProtection = s, + nameof(HeightStructuresCalculationConfiguration.FlowWidthAtBottomProtection), + testNameFormat, + true)) + { + yield return caseData; + } + foreach (TestCaseData caseData in StochastConfigurationCases( + (c, s) => c.WidthFlowApertures = s, + nameof(HeightStructuresCalculationConfiguration.WidthFlowApertures), + testNameFormat, + true)) + { + yield return caseData; + } + foreach (TestCaseData caseData in StochastConfigurationCases( + (c, s) => c.CriticalOvertoppingDischarge = s, + nameof(HeightStructuresCalculationConfiguration.CriticalOvertoppingDischarge), + testNameFormat, + false)) + { + yield return caseData; + } + foreach (TestCaseData caseData in StochastConfigurationCases( + (c, s) => c.StorageStructureArea = s, + nameof(HeightStructuresCalculationConfiguration.StorageStructureArea), + testNameFormat, + false)) + { + yield return caseData; + } + } + + private static IEnumerable StochastConfigurationCases( + Action modifyStochastAction, + string stochastName, + string testNameFormat, + bool standardDeviation) + { + var random = new Random(21); + + yield return new TestCaseData( + new Action(c => modifyStochastAction(c, new StochastConfiguration + { + Mean = random.NextDouble() + }))) + .SetName(string.Format(testNameFormat, $"{stochastName}Mean")); + + if (standardDeviation) + { + yield return new TestCaseData( + new Action(c => modifyStochastAction(c, new StochastConfiguration + { + StandardDeviation = random.NextDouble() + }))) + .SetName(string.Format(testNameFormat, $"{stochastName}StandardDeviation")); + } + else + { + yield return new TestCaseData( + new Action(c => modifyStochastAction(c, new StochastConfiguration + { + VariationCoefficient = random.NextDouble() + }))) + .SetName(string.Format(testNameFormat, $"{stochastName}VariationCoefficient")); + } + } } } \ No newline at end of file