Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil.Test/ClosingStructurePermutationHelperTest.cs =================================================================== diff -u --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil.Test/ClosingStructurePermutationHelperTest.cs (revision 0) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil.Test/ClosingStructurePermutationHelperTest.cs (revision 36d31be7cd357f771712dce5d134e0aba478042a) @@ -0,0 +1,117 @@ +// 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.Collections.Generic; +using System.Linq; +using NUnit.Framework; + +namespace Ringtoets.ClosingStructures.Data.TestUtil.Test +{ + [TestFixture] + public class ClosingStructurePermutationHelperTest + { + [Test] + public void DifferentClosingStructureWithSameId_ReturnsExpectedTestCaseData() + { + // Setup + var referenceStructure = new TestClosingStructure(); + var differentStructures = new List(); + + // Call + List testCaseDatas = ClosingStructurePermutationHelper.DifferentClosingStructuresWithSameId("A", "B").ToList(); + + // Assert + Assert.AreEqual(16, testCaseDatas.Count); + IEnumerable testNames = testCaseDatas + .Select(tcd => tcd.TestName) + .ToList(); + Assert.AreEqual(16, testNames.Distinct().Count()); + Assert.IsTrue(testNames.All(tn => tn.StartsWith("A_"))); + Assert.IsTrue(testNames.All(tn => tn.EndsWith("_B"))); + IEnumerable structures = testCaseDatas + .Select(tcd => tcd.Arguments[0]) + .OfType() + .ToList(); + Assert.AreEqual(16, structures.Count()); + Assert.IsTrue(structures.All(s => s.Id == structures.First().Id)); + differentStructures.Add(structures.Single(s => !s.Name.Equals(referenceStructure.Name))); + differentStructures.Add(structures.Single(s => !s.Location.Equals(referenceStructure.Location))); + differentStructures.Add(structures.Single(s => !s.AreaFlowApertures.Equals(referenceStructure.AreaFlowApertures))); + differentStructures.Add(structures.Single(s => !s.CriticalOvertoppingDischarge.Equals(referenceStructure.CriticalOvertoppingDischarge))); + differentStructures.Add(structures.Single(s => !s.FlowWidthAtBottomProtection.Equals(referenceStructure.FlowWidthAtBottomProtection))); + differentStructures.Add(structures.Single(s => !s.InsideWaterLevel.Equals(referenceStructure.InsideWaterLevel))); + differentStructures.Add(structures.Single(s => !s.LevelCrestStructureNotClosing.Equals(referenceStructure.LevelCrestStructureNotClosing))); + differentStructures.Add(structures.Single(s => !s.StorageStructureArea.Equals(referenceStructure.StorageStructureArea))); + differentStructures.Add(structures.Single(s => !s.ThresholdHeightOpenWeir.Equals(referenceStructure.ThresholdHeightOpenWeir))); + differentStructures.Add(structures.Single(s => !s.WidthFlowApertures.Equals(referenceStructure.WidthFlowApertures))); + differentStructures.Add(structures.Single(s => !s.FailureProbabilityReparation.Equals(referenceStructure.FailureProbabilityReparation))); + differentStructures.Add(structures.Single(s => !s.FailureProbabilityOpenStructure.Equals(referenceStructure.FailureProbabilityOpenStructure))); + differentStructures.Add(structures.Single(s => !s.IdenticalApertures.Equals(referenceStructure.IdenticalApertures))); + differentStructures.Add(structures.Single(s => !s.InflowModelType.Equals(referenceStructure.InflowModelType))); + differentStructures.Add(structures.Single(s => !s.ProbabilityOrFrequencyOpenStructureBeforeFlooding.Equals(referenceStructure.ProbabilityOrFrequencyOpenStructureBeforeFlooding))); + differentStructures.Add(structures.Single(s => !s.StructureNormalOrientation.Equals(referenceStructure.StructureNormalOrientation))); + Assert.AreEqual(16, differentStructures.Distinct().Count()); + } + + [Test] + public void DifferentClosingStructuresWithSameIdNameAndLocation_ReturnsExpectedTestCaseData() + { + // Setup + var referenceStructure = new TestClosingStructure(); + var differentStructures = new List(); + + // Call + List testCaseDatas = ClosingStructurePermutationHelper.DifferentClosingStructuresWithSameIdNameAndLocation("C", "D").ToList(); + + // Assert + Assert.AreEqual(14, testCaseDatas.Count); + IEnumerable testNames = testCaseDatas + .Select(tcd => tcd.TestName) + .ToList(); + Assert.AreEqual(14, testNames.Distinct().Count()); + Assert.IsTrue(testNames.All(tn => tn.StartsWith("C_"))); + Assert.IsTrue(testNames.All(tn => tn.EndsWith("_D"))); + IEnumerable structures = testCaseDatas + .Select(tcd => tcd.Arguments[0]) + .OfType() + .ToList(); + Assert.AreEqual(14, structures.Count()); + Assert.IsTrue(structures.All(s => s.Id == referenceStructure.Id)); + Assert.IsTrue(structures.All(s => s.Name == referenceStructure.Name)); + Assert.IsTrue(structures.All(s => s.Location.Equals(referenceStructure.Location))); + differentStructures.Add(structures.Single(s => !s.AreaFlowApertures.Equals(referenceStructure.AreaFlowApertures))); + differentStructures.Add(structures.Single(s => !s.CriticalOvertoppingDischarge.Equals(referenceStructure.CriticalOvertoppingDischarge))); + differentStructures.Add(structures.Single(s => !s.FlowWidthAtBottomProtection.Equals(referenceStructure.FlowWidthAtBottomProtection))); + differentStructures.Add(structures.Single(s => !s.InsideWaterLevel.Equals(referenceStructure.InsideWaterLevel))); + differentStructures.Add(structures.Single(s => !s.LevelCrestStructureNotClosing.Equals(referenceStructure.LevelCrestStructureNotClosing))); + differentStructures.Add(structures.Single(s => !s.StorageStructureArea.Equals(referenceStructure.StorageStructureArea))); + differentStructures.Add(structures.Single(s => !s.ThresholdHeightOpenWeir.Equals(referenceStructure.ThresholdHeightOpenWeir))); + differentStructures.Add(structures.Single(s => !s.WidthFlowApertures.Equals(referenceStructure.WidthFlowApertures))); + differentStructures.Add(structures.Single(s => !s.FailureProbabilityReparation.Equals(referenceStructure.FailureProbabilityReparation))); + differentStructures.Add(structures.Single(s => !s.FailureProbabilityOpenStructure.Equals(referenceStructure.FailureProbabilityOpenStructure))); + differentStructures.Add(structures.Single(s => !s.IdenticalApertures.Equals(referenceStructure.IdenticalApertures))); + differentStructures.Add(structures.Single(s => !s.InflowModelType.Equals(referenceStructure.InflowModelType))); + differentStructures.Add(structures.Single(s => !s.ProbabilityOrFrequencyOpenStructureBeforeFlooding.Equals(referenceStructure.ProbabilityOrFrequencyOpenStructureBeforeFlooding))); + differentStructures.Add(structures.Single(s => !s.StructureNormalOrientation.Equals(referenceStructure.StructureNormalOrientation))); + Assert.AreEqual(14, differentStructures.Distinct().Count()); + } + } +} \ No newline at end of file Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil.Test/Ringtoets.ClosingStructures.Data.TestUtil.Test.csproj =================================================================== diff -u -r37453954b2d36699ea16375cdfbf89785a094ab9 -r36d31be7cd357f771712dce5d134e0aba478042a --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil.Test/Ringtoets.ClosingStructures.Data.TestUtil.Test.csproj (.../Ringtoets.ClosingStructures.Data.TestUtil.Test.csproj) (revision 37453954b2d36699ea16375cdfbf89785a094ab9) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil.Test/Ringtoets.ClosingStructures.Data.TestUtil.Test.csproj (.../Ringtoets.ClosingStructures.Data.TestUtil.Test.csproj) (revision 36d31be7cd357f771712dce5d134e0aba478042a) @@ -49,6 +49,7 @@ Properties\GlobalAssembly.cs + Index: Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/ClosingStructurePermutationHelper.cs =================================================================== diff -u -rc5390b303f47e65a1a8e0ba271017c77dae24bbc -r36d31be7cd357f771712dce5d134e0aba478042a --- Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/ClosingStructurePermutationHelper.cs (.../ClosingStructurePermutationHelper.cs) (revision c5390b303f47e65a1a8e0ba271017c77dae24bbc) +++ Ringtoets/ClosingStructures/test/Ringtoets.ClosingStructures.Data.TestUtil/ClosingStructurePermutationHelper.cs (.../ClosingStructurePermutationHelper.cs) (revision 36d31be7cd357f771712dce5d134e0aba478042a) @@ -170,31 +170,31 @@ ClosingStructure.ConstructionProperties differentFailureProbabilityOpenStructureConstructionProperties = CreateTestClosingStructureConstructionProperties(); differentFailureProbabilityOpenStructureConstructionProperties.FailureProbabilityOpenStructure = random.NextDouble(); - yield return new TestCaseData(new ClosingStructure(CreateTestClosingStructureConstructionProperties())) + yield return new TestCaseData(new ClosingStructure(differentFailureProbabilityOpenStructureConstructionProperties)) .SetName($"{targetName}_DifferentFailureProbabilityOpenStructure_{testResultDescription}"); ClosingStructure.ConstructionProperties differentIdenticalAperturesProperties = CreateTestClosingStructureConstructionProperties(); differentIdenticalAperturesProperties.IdenticalApertures = random.Next(); - yield return new TestCaseData(new ClosingStructure(CreateTestClosingStructureConstructionProperties())) + yield return new TestCaseData(new ClosingStructure(differentIdenticalAperturesProperties)) .SetName($"{targetName}_DifferentIdenticalApertures_{testResultDescription}"); ClosingStructure.ConstructionProperties differentInflowModelTypeConstructionProperties = CreateTestClosingStructureConstructionProperties(); differentInflowModelTypeConstructionProperties.InflowModelType = random.NextEnumValue(); - yield return new TestCaseData(new ClosingStructure(CreateTestClosingStructureConstructionProperties())) + yield return new TestCaseData(new ClosingStructure(differentInflowModelTypeConstructionProperties)) .SetName($"{targetName}_DifferentInflowModelType_{testResultDescription}"); ClosingStructure.ConstructionProperties differentProbabilityOrFrequencyOpenStructureBeforeFloodingConstructionProperties = CreateTestClosingStructureConstructionProperties(); differentProbabilityOrFrequencyOpenStructureBeforeFloodingConstructionProperties.ProbabilityOrFrequencyOpenStructureBeforeFlooding = random.NextDouble(); - yield return new TestCaseData(new ClosingStructure(CreateTestClosingStructureConstructionProperties())) + yield return new TestCaseData(new ClosingStructure(differentProbabilityOrFrequencyOpenStructureBeforeFloodingConstructionProperties)) .SetName($"{targetName}_DifferentProbabilityOrFrequencyOpenStructureBeforeFlooding_{testResultDescription}"); ClosingStructure.ConstructionProperties differentStructureNormalOrientationConstructionProperties = CreateTestClosingStructureConstructionProperties(); differentStructureNormalOrientationConstructionProperties.StructureNormalOrientation = random.NextRoundedDouble(); - yield return new TestCaseData(new ClosingStructure(CreateTestClosingStructureConstructionProperties())) + yield return new TestCaseData(new ClosingStructure(differentStructureNormalOrientationConstructionProperties)) .SetName($"{targetName}_DifferentStructureNormalOrientation_{testResultDescription}"); }