Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/ClosingStructurePermutationHelper.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/ClosingStructurePermutationHelper.cs (revision 0) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/ClosingStructurePermutationHelper.cs (revision 5b29eb3dcd7369b6b4f2dc83785469e66e511fbb) @@ -0,0 +1,263 @@ +// Copyright (C) Stichting Deltares 2017. All rights reserved. +// +// This file is part of Ringtoets. +// +// Ringtoets is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. +// +// This program is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. +// +// You should have received a copy of the GNU General Public License +// along with this program. If not, see . +// +// All names, logos, and references to "Deltares" are registered trademarks of +// Stichting Deltares and remain full property of Stichting Deltares at all times. +// All rights reserved. + +using System; +using System.Collections.Generic; +using Core.Common.Base.Data; +using Core.Common.Base.Geometry; +using Core.Common.TestUtil; +using NUnit.Framework; + +namespace Ringtoets.ClosingStructures.Data.TestUtil +{ + /// + /// Helper containing a source of modified entities that can + /// be used in tests as a TestCaseSource. + /// + public static class ClosingStructurePermutationHelper + { + /// + /// Returns a collection of modified entities, which all differ + /// except for their id. + /// + /// The name of the test method to use the test case source for. + /// A description of the result of the test to use the test + /// case source for. + /// The collection of test case data. + /// + /// [TestCaseSource(typeof(ClosingStructurePermutationHelper), + /// nameof(ClosingStructurePermutationHelper.DifferentClosingStructuresWithSameId), + /// new object[] + /// { + /// "MethodName", + /// "TestResult" + /// })] + /// + public static IEnumerable DifferentClosingStructuresWithSameId(string testMethodName, string testResultDescription) + { + var referenceStructure = new TestClosingStructure(); + + var testCaseData = new List + { + new TestCaseData(new TestClosingStructure(referenceStructure.Id, "Different name")) + .SetName($"{testMethodName}_DifferentName_{testResultDescription}"), + new TestCaseData(new TestClosingStructure(new Point2D(1, 1), referenceStructure.Id)) + .SetName($"{testMethodName}_DifferentLocation_{testResultDescription}") + }; + + testCaseData.AddRange(DifferentClosingStructuresWithSameIdNameAndLocation(testMethodName, testResultDescription)); + + return testCaseData; + } + + /// + /// Returns a collection of modified entities, which all differ + /// except for their id, name and location. + /// + /// The name of the test method to use the test case source for. + /// A description of the result of the test to use the test + /// case source for. + /// The collection of test case data. + /// + /// [TestCaseSource(typeof(ClosingStructurePermutationHelper), + /// nameof(ClosingStructurePermutationHelper.DifferentClosingStructuresWithSameIdNameAndLocation), + /// new object[] + /// { + /// "MethodName", + /// "TestResult" + /// })] + /// + public static IEnumerable DifferentClosingStructuresWithSameIdNameAndLocation(string testMethodName, string testResultDescription) + { + var random = new Random(532); + + yield return new TestCaseData(new TestClosingStructure + { + AreaFlowApertures = + { + Mean = (RoundedDouble) random.Next(), + Shift = random.NextRoundedDouble(), + StandardDeviation = random.NextRoundedDouble() + } + }).SetName($"{testMethodName}_DifferentAreaFlowApertures_{testResultDescription}"); + + yield return new TestCaseData(new TestClosingStructure + { + CriticalOvertoppingDischarge = + { + Mean = (RoundedDouble) random.Next(), + CoefficientOfVariation = random.NextRoundedDouble() + } + }).SetName($"{testMethodName}_DifferentCriticalOvertoppingDischarge_{testResultDescription}"); + + yield return new TestCaseData(new TestClosingStructure + { + FlowWidthAtBottomProtection = + { + Mean = (RoundedDouble) random.Next(), + Shift = random.NextRoundedDouble(), + StandardDeviation = random.NextRoundedDouble() + } + }).SetName($"{testMethodName}_DifferentFlowWidthAtBottomProtection_{testResultDescription}"); + + yield return new TestCaseData(new TestClosingStructure + { + InsideWaterLevel = + { + Mean = (RoundedDouble) random.Next(), + StandardDeviation = random.NextRoundedDouble() + } + }).SetName($"{testMethodName}_DifferentInsideWaterLevel_{testResultDescription}"); + + yield return new TestCaseData(new TestClosingStructure + { + LevelCrestStructureNotClosing = + { + Mean = (RoundedDouble) random.Next(), + StandardDeviation = random.NextRoundedDouble() + } + }).SetName($"{testMethodName}_DifferentLevelCrestStructureNotClosing_{testResultDescription}"); + + yield return new TestCaseData(new TestClosingStructure + { + StorageStructureArea = + { + Mean = (RoundedDouble) random.Next(), + CoefficientOfVariation = random.NextRoundedDouble() + } + }).SetName($"{testMethodName}_DifferentStorageStructureArea_{testResultDescription}"); + + yield return new TestCaseData(new TestClosingStructure + { + ThresholdHeightOpenWeir = + { + Mean = (RoundedDouble) random.Next(), + StandardDeviation = random.NextRoundedDouble() + } + }).SetName($"{testMethodName}_DifferentThresholdHeightOpenWeir_{testResultDescription}"); + + yield return new TestCaseData(new TestClosingStructure + { + WidthFlowApertures = + { + Mean = (RoundedDouble) random.Next(), + StandardDeviation = random.NextRoundedDouble() + } + }).SetName($"{testMethodName}_DifferentWidthFlowApertures_{testResultDescription}"); + + ClosingStructure.ConstructionProperties differentFailureProbabilityReparationConstructionProperties = + CreateTestClosingStructureConstructionProperties(); + differentFailureProbabilityReparationConstructionProperties.FailureProbabilityReparation = random.NextDouble(); + yield return new TestCaseData(new ClosingStructure(differentFailureProbabilityReparationConstructionProperties)) + .SetName($"{testMethodName}_DifferentFailureProbabilityReparation_{testResultDescription}"); + + ClosingStructure.ConstructionProperties differentFailureProbabilityOpenStructureConstructionProperties = + CreateTestClosingStructureConstructionProperties(); + differentFailureProbabilityOpenStructureConstructionProperties.FailureProbabilityOpenStructure = random.NextDouble(); + yield return new TestCaseData(new ClosingStructure(CreateTestClosingStructureConstructionProperties())) + .SetName($"{testMethodName}_DifferentFailureProbabilityOpenStructure_{testResultDescription}"); + + ClosingStructure.ConstructionProperties differentIdenticalAperturesProperties = + CreateTestClosingStructureConstructionProperties(); + differentIdenticalAperturesProperties.IdenticalApertures = random.Next(); + yield return new TestCaseData(new ClosingStructure(CreateTestClosingStructureConstructionProperties())) + .SetName($"{testMethodName}_DifferentIdenticalApertures_{testResultDescription}"); + + ClosingStructure.ConstructionProperties differentInflowModelTypeConstructionProperties = + CreateTestClosingStructureConstructionProperties(); + differentInflowModelTypeConstructionProperties.InflowModelType = random.NextEnumValue(); + yield return new TestCaseData(new ClosingStructure(CreateTestClosingStructureConstructionProperties())) + .SetName($"{testMethodName}_DifferentInflowModelType_{testResultDescription}"); + + ClosingStructure.ConstructionProperties differentProbabilityOrFrequencyOpenStructureBeforeFloodingConstructionProperties = + CreateTestClosingStructureConstructionProperties(); + differentProbabilityOrFrequencyOpenStructureBeforeFloodingConstructionProperties.ProbabilityOrFrequencyOpenStructureBeforeFlooding = random.NextDouble(); + yield return new TestCaseData(new ClosingStructure(CreateTestClosingStructureConstructionProperties())) + .SetName($"{testMethodName}_DifferentProbabilityOrFrequencyOpenStructureBeforeFlooding_{testResultDescription}"); + + ClosingStructure.ConstructionProperties differentStructureNormalOrientationConstructionProperties = + CreateTestClosingStructureConstructionProperties(); + differentStructureNormalOrientationConstructionProperties.StructureNormalOrientation = random.NextRoundedDouble(); + yield return new TestCaseData(new ClosingStructure(CreateTestClosingStructureConstructionProperties())) + .SetName($"{testMethodName}_DifferentStructureNormalOrientation_{testResultDescription}"); + } + + private static ClosingStructure.ConstructionProperties CreateTestClosingStructureConstructionProperties() + { + var referenceStructure = new TestClosingStructure(); + + return new ClosingStructure.ConstructionProperties + { + Name = referenceStructure.Name, + Id = referenceStructure.Id, + Location = referenceStructure.Location, + AreaFlowApertures = + { + Mean = referenceStructure.AreaFlowApertures.Mean, + Shift = referenceStructure.AreaFlowApertures.Shift, + StandardDeviation = referenceStructure.AreaFlowApertures.StandardDeviation + }, + CriticalOvertoppingDischarge = + { + Mean = referenceStructure.CriticalOvertoppingDischarge.Mean, + CoefficientOfVariation = referenceStructure.CriticalOvertoppingDischarge.CoefficientOfVariation + }, + FlowWidthAtBottomProtection = + { + Mean = referenceStructure.FlowWidthAtBottomProtection.Mean, + Shift = referenceStructure.FlowWidthAtBottomProtection.Shift, + StandardDeviation = referenceStructure.FlowWidthAtBottomProtection.StandardDeviation + }, + InsideWaterLevel = + { + Mean = referenceStructure.InsideWaterLevel.Mean, + StandardDeviation = referenceStructure.InsideWaterLevel.StandardDeviation + }, + LevelCrestStructureNotClosing = + { + Mean = referenceStructure.LevelCrestStructureNotClosing.Mean, + StandardDeviation = referenceStructure.LevelCrestStructureNotClosing.StandardDeviation + }, + StorageStructureArea = + { + Mean = referenceStructure.StorageStructureArea.Mean, + CoefficientOfVariation = referenceStructure.StorageStructureArea.CoefficientOfVariation + }, + ThresholdHeightOpenWeir = + { + Mean = referenceStructure.ThresholdHeightOpenWeir.Mean, + StandardDeviation = referenceStructure.ThresholdHeightOpenWeir.StandardDeviation + }, + WidthFlowApertures = + { + Mean = referenceStructure.WidthFlowApertures.Mean, + StandardDeviation = referenceStructure.WidthFlowApertures.StandardDeviation + }, + FailureProbabilityReparation = referenceStructure.FailureProbabilityReparation, + FailureProbabilityOpenStructure = referenceStructure.FailureProbabilityOpenStructure, + IdenticalApertures = referenceStructure.IdenticalApertures, + InflowModelType = referenceStructure.InflowModelType, + ProbabilityOrFrequencyOpenStructureBeforeFlooding = referenceStructure.ProbabilityOrFrequencyOpenStructureBeforeFlooding, + StructureNormalOrientation = referenceStructure.StructureNormalOrientation + }; + } + } +} \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/Ringtoets.ClosingStructures.Data.TestUtil.csproj =================================================================== diff -u -r37453954b2d36699ea16375cdfbf89785a094ab9 -r5b29eb3dcd7369b6b4f2dc83785469e66e511fbb --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/Ringtoets.ClosingStructures.Data.TestUtil.csproj (.../Ringtoets.ClosingStructures.Data.TestUtil.csproj) (revision 37453954b2d36699ea16375cdfbf89785a094ab9) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/Ringtoets.ClosingStructures.Data.TestUtil.csproj (.../Ringtoets.ClosingStructures.Data.TestUtil.csproj) (revision 5b29eb3dcd7369b6b4f2dc83785469e66e511fbb) @@ -38,13 +38,18 @@ pdbonly + + ..\..\..\..\packages\NUnit.3.6.0\lib\net40\nunit.framework.dll + True + Properties\GlobalAssembly.cs + @@ -54,12 +59,17 @@ Copying.licenseheader + {3bbfd65b-b277-4e50-ae6d-bd24c3434609} Core.Common.Base + + {D749EE4C-CE50-4C17-BF01-9A953028C126} + Core.Common.TestUtil + {d4200f43-3f72-4f42-af0a-8ced416a38ec} Ringtoets.Common.Data Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/packages.config =================================================================== diff -u --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/packages.config (revision 0) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/packages.config (revision 5b29eb3dcd7369b6b4f2dc83785469e66e511fbb) @@ -0,0 +1,26 @@ + + + + + \ No newline at end of file