Example #1
0
        protected override StructuresStabilityPointCalculationInput CreateInput(StabilityPointStructuresInput structureInput,
                                                                                GeneralStabilityPointStructuresInput generalInput,
                                                                                string hydraulicBoundaryDatabaseFilePath,
                                                                                bool usePreprocessor)
        {
            StabilityPointStructureInflowModelType inflowModelType = structureInput.InflowModelType;

            if (!Enum.IsDefined(typeof(StabilityPointStructureInflowModelType), inflowModelType))
            {
                throw new InvalidEnumArgumentException(nameof(structureInput),
                                                       (int)inflowModelType,
                                                       typeof(StabilityPointStructureInflowModelType));
            }

            StructuresStabilityPointCalculationInput input;

            switch (inflowModelType)
            {
            case StabilityPointStructureInflowModelType.LowSill:
                input = CreateLowSillInput(structureInput, generalInput);
                break;

            case StabilityPointStructureInflowModelType.FloodedCulvert:
                input = CreateFloodedCulvertInput(structureInput, generalInput);
                break;

            default:
                throw new NotSupportedException();
            }

            HydraRingSettingsDatabaseHelper.AssignSettingsFromDatabase(input, hydraulicBoundaryDatabaseFilePath, usePreprocessor);
            return(input);
        }
        public IEnumerable <ValidationRule> GetValidationRules(StabilityPointStructuresInput input)
        {
            if (input == null)
            {
                throw new ArgumentNullException(nameof(input));
            }

            StabilityPointStructureInflowModelType inflowModelType = input.InflowModelType;

            if (!Enum.IsDefined(typeof(StabilityPointStructureInflowModelType), inflowModelType))
            {
                throw new InvalidEnumArgumentException(nameof(input),
                                                       (int)inflowModelType,
                                                       typeof(StabilityPointStructureInflowModelType));
            }

            IEnumerable <ValidationRule> validationRules;

            switch (inflowModelType)
            {
            case StabilityPointStructureInflowModelType.LowSill:
                validationRules = GetLowSillValidationRules(input);
                break;

            case StabilityPointStructureInflowModelType.FloodedCulvert:
                validationRules = GetFloodedCulvertValidationRules(input);
                break;

            default:
                throw new NotSupportedException();
            }

            return(validationRules);
        }
        public void ConvertTo_ForAllEnumValues_ReturnExpectedType(ConfigurationStabilityPointStructuresInflowModelType value,
                                                                  StabilityPointStructureInflowModelType expectedText)
        {
            // Setup
            var converter = new ConfigurationStabilityPointStructuresInflowModelTypeConverter();

            // Call
            object result = converter.ConvertTo(null, CultureInfo.CurrentCulture, value, typeof(StabilityPointStructureInflowModelType));

            // Assert
            Assert.AreEqual(expectedText, result);
        }
        public void ConvertFrom_InvalidStabilityPointStructureInflowModelType_ThrowInvalidEnumArgumentException()
        {
            // Setup
            var converter = new ConfigurationStabilityPointStructuresInflowModelTypeConverter();
            const StabilityPointStructureInflowModelType invalidValue = (StabilityPointStructureInflowModelType)983;

            // Call
            TestDelegate call = () => converter.ConvertFrom(invalidValue);

            // Assert
            string expectedMessage = $"The value of argument 'value' ({invalidValue}) is invalid for Enum type '{nameof(StabilityPointStructureInflowModelType)}'.";
            string parameterName   = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(call, expectedMessage).ParamName;

            Assert.AreEqual("value", parameterName);
        }
        /// <summary>
        /// Converts <paramref name="inflowModelType"/> to <see cref="ConfigurationStabilityPointStructuresInflowModelType"/>.
        /// </summary>
        /// <param name="inflowModelType">The <see cref="StabilityPointStructureInflowModelType"/> to convert.</param>
        /// <returns>The converted <paramref name="inflowModelType"/>.</returns>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="inflowModelType"/> is not supported.</exception>
        private static ConfigurationStabilityPointStructuresInflowModelType ConvertToConfigurationInflowModelType(StabilityPointStructureInflowModelType inflowModelType)
        {
            switch (inflowModelType)
            {
            case StabilityPointStructureInflowModelType.LowSill:
                return(ConfigurationStabilityPointStructuresInflowModelType.LowSill);

            case StabilityPointStructureInflowModelType.FloodedCulvert:
                return(ConfigurationStabilityPointStructuresInflowModelType.FloodedCulvert);

            default:
                throw new NotSupportedException();
            }
        }
        public void ConvertFrom_StabilityPointStructureInflowModelType_ReturnExpectedConfigurationInflowModelType(StabilityPointStructureInflowModelType value,
                                                                                                                  ConfigurationStabilityPointStructuresInflowModelType expectedResult)
        {
            // Setup
            var converter = new ConfigurationStabilityPointStructuresInflowModelTypeConverter();

            // Call
            object result = converter.ConvertFrom(value);

            // Assert
            Assert.AreEqual(expectedResult, result);
        }
Example #7
0
        public void GetValidationRules_InvalidLoadSchematizationType_ThrowsInvalidEnumArgumentException(StabilityPointStructureInflowModelType inflowModelType)
        {
            // Setup
            var registry = new StabilityPointStructuresValidationRulesRegistry();

            // Call
            TestDelegate test = () => registry.GetValidationRules(new StabilityPointStructuresInput
            {
                InflowModelType        = inflowModelType,
                LoadSchematizationType = (LoadSchematizationType)99
            });

            // Assert
            const string message = "The value of argument 'input' (99) is invalid for Enum type 'LoadSchematizationType'.";

            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(test, message);
        }
        /// <summary>
        /// Copies the property values of the <paramref name="fromStructure"/> to the
        /// <see cref="StabilityPointStructure"/>.
        /// </summary>
        /// <param name="fromStructure">The <see cref="StabilityPointStructure"/> to get the property
        /// values from.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="fromStructure"/>
        /// is <c>null</c>.</exception>
        public void CopyProperties(StabilityPointStructure fromStructure)
        {
            base.CopyProperties(fromStructure);

            StorageStructureArea.Mean = fromStructure.StorageStructureArea.Mean;
            StorageStructureArea.CoefficientOfVariation = fromStructure.StorageStructureArea.CoefficientOfVariation;

            AllowedLevelIncreaseStorage.Mean = fromStructure.AllowedLevelIncreaseStorage.Mean;
            AllowedLevelIncreaseStorage.StandardDeviation = fromStructure.AllowedLevelIncreaseStorage.StandardDeviation;

            WidthFlowApertures.Mean = fromStructure.WidthFlowApertures.Mean;
            WidthFlowApertures.StandardDeviation = fromStructure.WidthFlowApertures.StandardDeviation;

            InsideWaterLevel.Mean = fromStructure.InsideWaterLevel.Mean;
            InsideWaterLevel.StandardDeviation = fromStructure.InsideWaterLevel.StandardDeviation;

            ThresholdHeightOpenWeir.Mean = fromStructure.ThresholdHeightOpenWeir.Mean;
            ThresholdHeightOpenWeir.StandardDeviation = fromStructure.ThresholdHeightOpenWeir.StandardDeviation;

            CriticalOvertoppingDischarge.Mean = fromStructure.CriticalOvertoppingDischarge.Mean;
            CriticalOvertoppingDischarge.CoefficientOfVariation = fromStructure.CriticalOvertoppingDischarge.CoefficientOfVariation;

            FlowWidthAtBottomProtection.Mean = fromStructure.FlowWidthAtBottomProtection.Mean;
            FlowWidthAtBottomProtection.StandardDeviation = fromStructure.FlowWidthAtBottomProtection.StandardDeviation;

            ConstructiveStrengthLinearLoadModel.Mean = fromStructure.ConstructiveStrengthLinearLoadModel.Mean;
            ConstructiveStrengthLinearLoadModel.CoefficientOfVariation = fromStructure.ConstructiveStrengthLinearLoadModel.CoefficientOfVariation;

            ConstructiveStrengthQuadraticLoadModel.Mean = fromStructure.ConstructiveStrengthQuadraticLoadModel.Mean;
            ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation = fromStructure.ConstructiveStrengthQuadraticLoadModel.CoefficientOfVariation;

            BankWidth.Mean = fromStructure.BankWidth.Mean;
            BankWidth.StandardDeviation = fromStructure.BankWidth.StandardDeviation;

            InsideWaterLevelFailureConstruction.Mean = fromStructure.InsideWaterLevelFailureConstruction.Mean;
            InsideWaterLevelFailureConstruction.StandardDeviation = fromStructure.InsideWaterLevelFailureConstruction.StandardDeviation;

            EvaluationLevel = fromStructure.EvaluationLevel;

            LevelCrestStructure.Mean = fromStructure.LevelCrestStructure.Mean;
            LevelCrestStructure.StandardDeviation = fromStructure.LevelCrestStructure.StandardDeviation;

            VerticalDistance = fromStructure.VerticalDistance;
            FailureProbabilityRepairClosure = fromStructure.FailureProbabilityRepairClosure;

            FailureCollisionEnergy.Mean = fromStructure.FailureCollisionEnergy.Mean;
            FailureCollisionEnergy.CoefficientOfVariation = fromStructure.FailureCollisionEnergy.CoefficientOfVariation;

            ShipMass.Mean = fromStructure.ShipMass.Mean;
            ShipMass.CoefficientOfVariation = fromStructure.ShipMass.CoefficientOfVariation;

            ShipVelocity.Mean = fromStructure.ShipVelocity.Mean;
            ShipVelocity.CoefficientOfVariation = fromStructure.ShipVelocity.CoefficientOfVariation;

            LevellingCount = fromStructure.LevellingCount;
            ProbabilityCollisionSecondaryStructure = fromStructure.ProbabilityCollisionSecondaryStructure;

            FlowVelocityStructureClosable.Mean = fromStructure.FlowVelocityStructureClosable.Mean;

            StabilityLinearLoadModel.Mean = fromStructure.StabilityLinearLoadModel.Mean;
            StabilityLinearLoadModel.CoefficientOfVariation = fromStructure.StabilityLinearLoadModel.CoefficientOfVariation;

            StabilityQuadraticLoadModel.Mean = fromStructure.StabilityQuadraticLoadModel.Mean;
            StabilityQuadraticLoadModel.CoefficientOfVariation = fromStructure.StabilityQuadraticLoadModel.CoefficientOfVariation;

            AreaFlowApertures.Mean = fromStructure.AreaFlowApertures.Mean;
            AreaFlowApertures.StandardDeviation = fromStructure.AreaFlowApertures.StandardDeviation;

            InflowModelType = fromStructure.InflowModelType;
        }