private static IEnumerable <TestCaseData> GetUnequalTestCases()
            {
                foreach (ChangePropertyData <ClosingStructure.ConstructionProperties> changeSingleDataProperty in ChangeSingleDataProperties())
                {
                    ClosingStructure.ConstructionProperties differentConstructionProperties = CreateConstructionProperties();
                    changeSingleDataProperty.ActionToChangeProperty(differentConstructionProperties);

                    yield return(new TestCaseData(new ClosingStructure(differentConstructionProperties))
                                 .SetName(changeSingleDataProperty.PropertyName));
                }
            }
Exemple #2
0
        /// <summary>
        /// Creates a <see cref="ClosingStructure"/> based on the <paramref name="structureLocation"/>
        /// and property values defined by <paramref name="structureParameterRows"/>.
        /// </summary>
        /// <param name="structureLocation">The representation of the structure.</param>
        /// <param name="structureParameterRows">The parameters of the structure.</param>
        /// <returns>A <see cref="ClosingStructure"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="structureParameterRows"/>
        /// contains an element with <see cref="StructuresParameterRow.ParameterId"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="structureParameterRows"/>
        /// contains a parameter definition with a duplicate name.</exception>
        private ClosingStructure CreateClosingStructure(StructureLocation structureLocation,
                                                        IEnumerable <StructuresParameterRow> structureParameterRows)
        {
            Dictionary <string, StructuresParameterRow> rowData = structureParameterRows.ToDictionary(
                row => row.ParameterId, row => row, StringComparer.OrdinalIgnoreCase);

            string structureName          = structureLocation.Name;
            string structureId            = structureLocation.Id;
            var    constructionProperties = new ClosingStructure.ConstructionProperties
            {
                Name     = structureName,
                Id       = structureId,
                Location = structureLocation.Point
            };

            TrySetConstructionProperty((rows, key) =>
            {
                constructionProperties.StorageStructureArea.Mean = (RoundedDouble)rows[key].NumericalValue;
                constructionProperties.StorageStructureArea.CoefficientOfVariation = GetCoefficientOfVariation(rows[key], structureName);
            },
                                       rowData,
                                       StructureFilesKeywords.ClosingStructureParameterKeyword1,
                                       structureName,
                                       structureId);

            TrySetConstructionProperty((rows, key) =>
            {
                constructionProperties.AllowedLevelIncreaseStorage.Mean = (RoundedDouble)rows[key].NumericalValue;
                constructionProperties.AllowedLevelIncreaseStorage.StandardDeviation = GetStandardDeviation(rows[key], structureName);
            },
                                       rowData,
                                       StructureFilesKeywords.ClosingStructureParameterKeyword2,
                                       structureName,
                                       structureId);

            TrySetConstructionProperty((rows, key) => constructionProperties.StructureNormalOrientation = (RoundedDouble)rows[key].NumericalValue,
                                       rowData,
                                       StructureFilesKeywords.ClosingStructureParameterKeyword3,
                                       structureName,
                                       structureId);

            TrySetConstructionProperty((rows, key) =>
            {
                constructionProperties.WidthFlowApertures.Mean = (RoundedDouble)rows[key].NumericalValue;
                constructionProperties.WidthFlowApertures.StandardDeviation = GetStandardDeviation(rows[key], structureName);
            },
                                       rowData,
                                       StructureFilesKeywords.ClosingStructureParameterKeyword4,
                                       structureName,
                                       structureId);

            TrySetConstructionProperty((rows, key) =>
            {
                constructionProperties.LevelCrestStructureNotClosing.Mean = (RoundedDouble)rows[key].NumericalValue;
                constructionProperties.LevelCrestStructureNotClosing.StandardDeviation = GetStandardDeviation(rows[key], structureName);
            },
                                       rowData,
                                       StructureFilesKeywords.ClosingStructureParameterKeyword5,
                                       structureName,
                                       structureId);

            TrySetConstructionProperty((rows, key) =>
            {
                constructionProperties.InsideWaterLevel.Mean = (RoundedDouble)rows[key].NumericalValue;
                constructionProperties.InsideWaterLevel.StandardDeviation = GetStandardDeviation(rows[key], structureName);
            },
                                       rowData,
                                       StructureFilesKeywords.ClosingStructureParameterKeyword6,
                                       structureName,
                                       structureId);

            TrySetConstructionProperty((rows, key) =>
            {
                constructionProperties.ThresholdHeightOpenWeir.Mean = (RoundedDouble)rows[key].NumericalValue;
                constructionProperties.ThresholdHeightOpenWeir.StandardDeviation = GetStandardDeviation(rows[key], structureName);
            },
                                       rowData,
                                       StructureFilesKeywords.ClosingStructureParameterKeyword7,
                                       structureName,
                                       structureId);

            TrySetConstructionProperty((rows, key) =>
            {
                constructionProperties.AreaFlowApertures.Mean = (RoundedDouble)rows[key].NumericalValue;
                constructionProperties.AreaFlowApertures.StandardDeviation = GetStandardDeviation(rows[key], structureName);
            },
                                       rowData,
                                       StructureFilesKeywords.ClosingStructureParameterKeyword8,
                                       structureName,
                                       structureId);

            TrySetConstructionProperty((rows, key) =>
            {
                constructionProperties.CriticalOvertoppingDischarge.Mean = (RoundedDouble)rows[key].NumericalValue;
                constructionProperties.CriticalOvertoppingDischarge.CoefficientOfVariation = GetCoefficientOfVariation(rows[key], structureName);
            },
                                       rowData,
                                       StructureFilesKeywords.ClosingStructureParameterKeyword9,
                                       structureName,
                                       structureId);

            TrySetConstructionProperty((rows, key) =>
            {
                constructionProperties.FlowWidthAtBottomProtection.Mean = (RoundedDouble)rows[key].NumericalValue;
                constructionProperties.FlowWidthAtBottomProtection.StandardDeviation = GetStandardDeviation(rows[key], structureName);
            },
                                       rowData,
                                       StructureFilesKeywords.ClosingStructureParameterKeyword10,
                                       structureName,
                                       structureId);

            TrySetConstructionProperty((rows, key) => constructionProperties.ProbabilityOpenStructureBeforeFlooding = rows[key].NumericalValue,
                                       rowData,
                                       StructureFilesKeywords.ClosingStructureParameterKeyword11,
                                       structureName,
                                       structureId);

            TrySetConstructionProperty((rows, key) => constructionProperties.FailureProbabilityOpenStructure = rows[key].NumericalValue,
                                       rowData,
                                       StructureFilesKeywords.ClosingStructureParameterKeyword12,
                                       structureName,
                                       structureId);

            TrySetConstructionProperty((rows, key) => constructionProperties.IdenticalApertures = (int)rows[key].NumericalValue,
                                       rowData,
                                       StructureFilesKeywords.ClosingStructureParameterKeyword13,
                                       structureName,
                                       structureId);

            TrySetConstructionProperty((rows, key) => constructionProperties.FailureProbabilityReparation = rows[key].NumericalValue,
                                       rowData,
                                       StructureFilesKeywords.ClosingStructureParameterKeyword14,
                                       structureName,
                                       structureId);

            TrySetConstructionProperty((rows, key) => constructionProperties.InflowModelType = GetClosingStructureInflowModelType(rows[key]),
                                       rowData,
                                       StructureFilesKeywords.ClosingStructureParameterKeyword15,
                                       structureName,
                                       structureId);

            return(new ClosingStructure(constructionProperties));
        }
Exemple #3
0
        /// <summary>
        /// Returns a collection of modified <see cref="ClosingStructure"/> entities, which all differ
        /// except for their id, name and location.
        /// </summary>
        /// <param name="targetName">The name of the target to test while using the test case source.</param>
        /// <param name="testResultDescription">A description of the result of the test while using the test case source.</param>
        /// <returns>The collection of test case data.</returns>
        /// <example>
        /// <code>
        /// [TestCaseSource(
        ///     typeof(ClosingStructurePermutationHelper),
        ///     nameof(ClosingStructurePermutationHelper.DifferentClosingStructuresWithSameIdNameAndLocation),
        ///     new object[]
        ///     {
        ///         "TargetMethodName",
        ///         "TestResult"
        ///     })]
        /// </code>
        /// </example>
        public static IEnumerable <TestCaseData> DifferentClosingStructuresWithSameIdNameAndLocation(string targetName, string testResultDescription)
        {
            var random = new Random(532);

            yield return(new TestCaseData(new TestClosingStructure
            {
                AllowedLevelIncreaseStorage =
                {
                    Mean = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentAllowedLevelIncreaseStorageMean_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                AllowedLevelIncreaseStorage =
                {
                    StandardDeviation = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentAllowedLevelIncreaseStorageStandardDeviation_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                AreaFlowApertures =
                {
                    Mean = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentAreaFlowAperturesMean_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                AreaFlowApertures =
                {
                    StandardDeviation = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentAreaFlowAperturesStandardDeviation_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                CriticalOvertoppingDischarge =
                {
                    Mean = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentCriticalOvertoppingDischargeMean_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                CriticalOvertoppingDischarge =
                {
                    CoefficientOfVariation = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentCriticalOvertoppingDischargeCoefficientOfVariation_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                FlowWidthAtBottomProtection =
                {
                    Mean = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentFlowWidthAtBottomProtectionMean_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                FlowWidthAtBottomProtection =
                {
                    StandardDeviation = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentFlowWidthAtBottomProtectionStandardDeviation_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                InsideWaterLevel =
                {
                    Mean = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentInsideWaterLevelMean_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                InsideWaterLevel =
                {
                    StandardDeviation = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentInsideWaterLevelStandardDeviation_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                LevelCrestStructureNotClosing =
                {
                    Mean = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentLevelCrestStructureNotClosingMean_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                LevelCrestStructureNotClosing =
                {
                    StandardDeviation = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentLevelCrestStructureNotClosingStandardDeviation_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                StorageStructureArea =
                {
                    Mean = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentStorageStructureAreaMean_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                StorageStructureArea =
                {
                    CoefficientOfVariation = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentStorageStructureAreaCoefficientOfVariation_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                ThresholdHeightOpenWeir =
                {
                    Mean = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentThresholdHeightOpenWeirMean_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                ThresholdHeightOpenWeir =
                {
                    StandardDeviation = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentThresholdHeightOpenWeirStandardDeviation_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                WidthFlowApertures =
                {
                    Mean = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentWidthFlowAperturesMean_{testResultDescription}"));

            yield return(new TestCaseData(new TestClosingStructure
            {
                WidthFlowApertures =
                {
                    StandardDeviation = random.NextRoundedDouble()
                }
            }).SetName($"{targetName}_DifferentWidthFlowAperturesStandardDeviation_{testResultDescription}"));

            ClosingStructure.ConstructionProperties differentFailureProbabilityReparationConstructionProperties =
                CreateTestClosingStructureConstructionProperties();
            differentFailureProbabilityReparationConstructionProperties.FailureProbabilityReparation = random.NextDouble();
            yield return(new TestCaseData(new ClosingStructure(differentFailureProbabilityReparationConstructionProperties))
                         .SetName($"{targetName}_DifferentFailureProbabilityReparation_{testResultDescription}"));

            ClosingStructure.ConstructionProperties differentFailureProbabilityOpenStructureConstructionProperties =
                CreateTestClosingStructureConstructionProperties();
            differentFailureProbabilityOpenStructureConstructionProperties.FailureProbabilityOpenStructure = random.NextDouble();
            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(differentIdenticalAperturesProperties))
                         .SetName($"{targetName}_DifferentIdenticalApertures_{testResultDescription}"));

            ClosingStructure.ConstructionProperties differentInflowModelTypeConstructionProperties =
                CreateTestClosingStructureConstructionProperties();
            differentInflowModelTypeConstructionProperties.InflowModelType = ClosingStructureInflowModelType.LowSill;
            yield return(new TestCaseData(new ClosingStructure(differentInflowModelTypeConstructionProperties))
                         .SetName($"{targetName}_DifferentInflowModelType_{testResultDescription}"));

            ClosingStructure.ConstructionProperties differentProbabilityOpenStructureBeforeFloodingConstructionProperties =
                CreateTestClosingStructureConstructionProperties();
            differentProbabilityOpenStructureBeforeFloodingConstructionProperties.ProbabilityOpenStructureBeforeFlooding = random.NextDouble();
            yield return(new TestCaseData(new ClosingStructure(differentProbabilityOpenStructureBeforeFloodingConstructionProperties))
                         .SetName($"{targetName}_DifferentProbabilityOpenStructureBeforeFlooding_{testResultDescription}"));

            ClosingStructure.ConstructionProperties differentStructureNormalOrientationConstructionProperties =
                CreateTestClosingStructureConstructionProperties();
            differentStructureNormalOrientationConstructionProperties.StructureNormalOrientation = random.NextRoundedDouble();
            yield return(new TestCaseData(new ClosingStructure(differentStructureNormalOrientationConstructionProperties))
                         .SetName($"{targetName}_DifferentStructureNormalOrientation_{testResultDescription}"));
        }