/// <summary> /// Creates a <see cref="StabilityPointStructure"/> 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="StabilityPointStructure"/>.</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 StabilityPointStructure CreateStabilityPointStructure(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 StabilityPointStructure.ConstructionProperties { Name = structureName, Id = structureId, Location = structureLocation.Point }; TrySetConstructionProperty((rows, key) => constructionProperties.StructureNormalOrientation = (RoundedDouble)rows[key].NumericalValue, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword1, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.StorageStructureArea.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.StorageStructureArea.CoefficientOfVariation = GetCoefficientOfVariation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword2, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.AllowedLevelIncreaseStorage.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.AllowedLevelIncreaseStorage.StandardDeviation = GetStandardDeviation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword3, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.WidthFlowApertures.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.WidthFlowApertures.StandardDeviation = GetStandardDeviation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword4, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.InsideWaterLevel.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.InsideWaterLevel.StandardDeviation = GetStandardDeviation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword5, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.ThresholdHeightOpenWeir.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.ThresholdHeightOpenWeir.StandardDeviation = GetStandardDeviation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword6, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.CriticalOvertoppingDischarge.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.CriticalOvertoppingDischarge.CoefficientOfVariation = GetCoefficientOfVariation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword7, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.FlowWidthAtBottomProtection.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.FlowWidthAtBottomProtection.StandardDeviation = GetStandardDeviation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword8, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.ConstructiveStrengthLinearLoadModel.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.ConstructiveStrengthLinearLoadModel.CoefficientOfVariation = GetCoefficientOfVariation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword9, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.ConstructiveStrengthQuadraticLoadModel.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation = GetCoefficientOfVariation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword10, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.BankWidth.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.BankWidth.StandardDeviation = GetStandardDeviation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword11, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.InsideWaterLevelFailureConstruction.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.InsideWaterLevelFailureConstruction.StandardDeviation = GetStandardDeviation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword12, structureName, structureId); TrySetConstructionProperty((rows, key) => constructionProperties.EvaluationLevel = rows[key].NumericalValue, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword13, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.LevelCrestStructure.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.LevelCrestStructure.StandardDeviation = GetStandardDeviation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword14, structureName, structureId); TrySetConstructionProperty((rows, key) => constructionProperties.VerticalDistance = rows[key].NumericalValue, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword15, structureName, structureId); TrySetConstructionProperty((rows, key) => constructionProperties.FailureProbabilityRepairClosure = rows[key].NumericalValue, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword16, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.FailureCollisionEnergy.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.FailureCollisionEnergy.CoefficientOfVariation = GetCoefficientOfVariation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword17, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.ShipMass.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.ShipMass.CoefficientOfVariation = GetCoefficientOfVariation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword18, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.ShipVelocity.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.ShipVelocity.CoefficientOfVariation = GetCoefficientOfVariation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword19, structureName, structureId); TrySetConstructionProperty((rows, key) => constructionProperties.LevellingCount = (int)rows[key].NumericalValue, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword20, structureName, structureId); TrySetConstructionProperty((rows, key) => constructionProperties.ProbabilityCollisionSecondaryStructure = rows[key].NumericalValue, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword21, structureName, structureId); TrySetConstructionProperty((rows, key) => constructionProperties.FlowVelocityStructureClosable.Mean = (RoundedDouble)rows[key].NumericalValue, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword22, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.StabilityLinearLoadModel.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.StabilityLinearLoadModel.CoefficientOfVariation = GetCoefficientOfVariation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword23, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.StabilityQuadraticLoadModel.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.StabilityQuadraticLoadModel.CoefficientOfVariation = GetCoefficientOfVariation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword24, structureName, structureId); TrySetConstructionProperty((rows, key) => { constructionProperties.AreaFlowApertures.Mean = (RoundedDouble)rows[key].NumericalValue; constructionProperties.AreaFlowApertures.StandardDeviation = GetStandardDeviation(rows[key], structureName); }, rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword25, structureName, structureId); TrySetConstructionProperty((rows, key) => constructionProperties.InflowModelType = GetStabilityPointStructureInflowModelType(rows[key]), rowData, StructureFilesKeywords.StabilityPointStructureParameterKeyword26, structureName, structureId); return(new StabilityPointStructure(constructionProperties)); }
/// <summary> /// Returns a collection of modified <see cref="StabilityPointStructure"/> 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(StabilityPointStructurePermutationHelper), /// nameof(StabilityPointStructurePermutationHelper.DifferentStabilityPointStructuresWithSameIdNameAndLocation), /// new object[] /// { /// "TargetMethodName", /// "TestResult" /// })] /// </code> /// </example> public static IEnumerable <TestCaseData> DifferentStabilityPointStructuresWithSameIdNameAndLocation(string targetName, string testResultDescription) { var random = new Random(532); yield return(new TestCaseData(new TestStabilityPointStructure { StorageStructureArea = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentStorageStructureAreaMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { StorageStructureArea = { CoefficientOfVariation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentStorageStructureAreaCoefficientOfVariation_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { AllowedLevelIncreaseStorage = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentAllowedLevelIncreaseStorageMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { AllowedLevelIncreaseStorage = { StandardDeviation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentAllowedLevelIncreaseStorageStandardDeviation_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { WidthFlowApertures = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentWidthFlowAperturesMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { WidthFlowApertures = { StandardDeviation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentWidthFlowAperturesStandardDeviation_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { InsideWaterLevel = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentInsideWaterLevelMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { InsideWaterLevel = { StandardDeviation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentInsideWaterLevelStandardDeviation_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { ThresholdHeightOpenWeir = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentThresholdHeightOpenWeirMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { ThresholdHeightOpenWeir = { StandardDeviation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentThresholdHeightOpenWeirStandardDeviation_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { CriticalOvertoppingDischarge = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentCriticalOvertoppingDischargeMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { CriticalOvertoppingDischarge = { CoefficientOfVariation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentCriticalOvertoppingDischargeCoefficientOfVariation_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { FlowWidthAtBottomProtection = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentFlowWidthAtBottomProtectionMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { FlowWidthAtBottomProtection = { StandardDeviation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentFlowWidthAtBottomProtectionStandardDeviation_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { ConstructiveStrengthLinearLoadModel = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentConstructiveStrengthLinearLoadModelMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { ConstructiveStrengthLinearLoadModel = { CoefficientOfVariation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentConstructiveStrengthLinearLoadModelCoefficientOfVariation_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { ConstructiveStrengthQuadraticLoadModel = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentConstructiveStrengthQuadraticLoadModelMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { ConstructiveStrengthQuadraticLoadModel = { CoefficientOfVariation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentConstructiveStrengthQuadraticLoadModelCoefficientOfVariation_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { BankWidth = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentBankWidthMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { BankWidth = { StandardDeviation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentBankWidthStandardDeviation_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { InsideWaterLevelFailureConstruction = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentInsideWaterLevelFailureConstructionMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { InsideWaterLevelFailureConstruction = { StandardDeviation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentInsideWaterLevelFailureConstructionStandardDeviation_{testResultDescription}")); StabilityPointStructure.ConstructionProperties differentEvaluationLevelConstructionProperties = CreateTestStabilityPointStructureConstructionProperties(); differentEvaluationLevelConstructionProperties.EvaluationLevel = random.NextDouble(); yield return(new TestCaseData(new StabilityPointStructure(differentEvaluationLevelConstructionProperties)) .SetName($"{targetName}_DifferentEvaluationLevel_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { LevelCrestStructure = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentLevelCrestStructureMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { LevelCrestStructure = { StandardDeviation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentLevelCrestStructureStandardDeviation_{testResultDescription}")); StabilityPointStructure.ConstructionProperties differentVerticalDistanceConstructionProperties = CreateTestStabilityPointStructureConstructionProperties(); differentVerticalDistanceConstructionProperties.VerticalDistance = random.NextDouble(); yield return(new TestCaseData(new StabilityPointStructure(differentVerticalDistanceConstructionProperties)) .SetName($"{targetName}_DifferentVerticalDistance_{testResultDescription}")); StabilityPointStructure.ConstructionProperties differentFailureProbabilityRepairClosureConstructionProperties = CreateTestStabilityPointStructureConstructionProperties(); differentFailureProbabilityRepairClosureConstructionProperties.FailureProbabilityRepairClosure = random.NextDouble(); yield return(new TestCaseData(new StabilityPointStructure(differentFailureProbabilityRepairClosureConstructionProperties)) .SetName($"{targetName}_DifferentFailureProbabilityRepairClosure_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { FailureCollisionEnergy = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentFailureCollisionEnergyMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { FailureCollisionEnergy = { CoefficientOfVariation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentFailureCollisionEnergyCoefficientOfVariation_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { ShipMass = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentShipMassMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { ShipMass = { CoefficientOfVariation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentShipMassCoefficientOfVariation_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { ShipVelocity = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentShipVelocityMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { ShipVelocity = { CoefficientOfVariation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentShipVelocityCoefficientOfVariation_{testResultDescription}")); StabilityPointStructure.ConstructionProperties differentLevellingCountConstructionProperties = CreateTestStabilityPointStructureConstructionProperties(); differentLevellingCountConstructionProperties.LevellingCount = random.Next(); yield return(new TestCaseData(new StabilityPointStructure(differentLevellingCountConstructionProperties)) .SetName($"{targetName}_DifferentLevellingCount_{testResultDescription}")); StabilityPointStructure.ConstructionProperties differentProbabilityCollisionSecondaryStructureConstructionProperties = CreateTestStabilityPointStructureConstructionProperties(); differentProbabilityCollisionSecondaryStructureConstructionProperties.ProbabilityCollisionSecondaryStructure = random.NextDouble(); yield return(new TestCaseData(new StabilityPointStructure(differentProbabilityCollisionSecondaryStructureConstructionProperties)) .SetName($"{targetName}_DifferentProbabilityCollisionSecondaryStructure_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { FlowVelocityStructureClosable = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentFlowVelocityStructureClosableMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { StabilityLinearLoadModel = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentStabilityLinearLoadModelMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { StabilityLinearLoadModel = { CoefficientOfVariation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentStabilityLinearLoadModelCoefficientOfVariation_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { StabilityQuadraticLoadModel = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentStabilityQuadraticLoadModelMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { StabilityQuadraticLoadModel = { CoefficientOfVariation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentStabilityQuadraticLoadModelCoefficientOfVariation_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { AreaFlowApertures = { Mean = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentAreaFlowAperturesMean_{testResultDescription}")); yield return(new TestCaseData(new TestStabilityPointStructure { AreaFlowApertures = { StandardDeviation = random.NextRoundedDouble() } }).SetName($"{targetName}_DifferentAreaFlowAperturesStandardDeviation_{testResultDescription}")); StabilityPointStructure.ConstructionProperties differentInflowModelTypeConstructionProperties = CreateTestStabilityPointStructureConstructionProperties(); differentInflowModelTypeConstructionProperties.InflowModelType = StabilityPointStructureInflowModelType.LowSill; yield return(new TestCaseData(new StabilityPointStructure(differentInflowModelTypeConstructionProperties)) .SetName($"{targetName}_DifferentInflowModelType_{testResultDescription}")); }