Exemplo n.º 1
0
        public void GivenInputWithStructure_WhenStructureNull_ThenSchematizationPropertiesSynedToDefaults()
        {
            // Given
            var structure = new TestStructure();
            var input     = new SimpleStructuresInput
            {
                Structure = structure,
                FailureProbabilityStructureWithErosion = 0.99
            };

            VariationCoefficientLogNormalDistribution expectedStormDuration = input.StormDuration;
            double expectedFailureProbabilityStructureWithErosion           = input.FailureProbabilityStructureWithErosion;

            // Precondition
            Assert.AreSame(structure, input.Structure);

            // When
            input.Structure = null;

            // Then
            DistributionAssert.AreEqual(expectedStormDuration, input.StormDuration);

            AssertAreEqual(double.NaN, input.StructureNormalOrientation);
            Assert.AreEqual(2, input.StructureNormalOrientation.NumberOfDecimalPlaces);

            var expectedAllowedLevelIncreaseStorage = new LogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            var expectedStorageStructureArea = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedFlowWidthAtBottomProtection = new LogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            var expectedCriticalOvertoppingDischarge = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedWidthFlowApertures = new NormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            DistributionAssert.AreEqual(expectedAllowedLevelIncreaseStorage, input.AllowedLevelIncreaseStorage);
            DistributionAssert.AreEqual(expectedStorageStructureArea, input.StorageStructureArea);
            DistributionAssert.AreEqual(expectedFlowWidthAtBottomProtection, input.FlowWidthAtBottomProtection);
            DistributionAssert.AreEqual(expectedCriticalOvertoppingDischarge, input.CriticalOvertoppingDischarge);
            DistributionAssert.AreEqual(expectedWidthFlowApertures, input.WidthFlowApertures);

            Assert.AreEqual(expectedFailureProbabilityStructureWithErosion, input.FailureProbabilityStructureWithErosion);
        }
Exemplo n.º 2
0
        public void Import_MissingParametersAndDuplicateIrrelevantParameter_LogWarningAndContinueImportWithDefaultValues()
        {
            // Setup
            string filePath = Path.Combine(testDataPath, nameof(StabilityPointStructuresImporter),
                                           "MissingAndDuplicateIrrelevantParameters", "Kunstwerken.shp");

            var importTarget = new StructureCollection <StabilityPointStructure>();

            var messageProvider = mocks.Stub <IImporterMessageProvider>();
            var updateStrategy  = mocks.Stub <IStructureUpdateStrategy <StabilityPointStructure> >();

            updateStrategy.Expect(u => u.UpdateStructuresWithImportedData(null, null)).IgnoreArguments().WhenCalled(i =>
            {
                Assert.AreEqual(filePath, i.Arguments[1]);

                var readStructures = (IEnumerable <StabilityPointStructure>)i.Arguments[0];

                Assert.AreEqual(1, readStructures.Count());
                StabilityPointStructure importedStructure = readStructures.First();
                var defaultStructure = new StabilityPointStructure(new StabilityPointStructure.ConstructionProperties
                {
                    Name     = "test",
                    Location = new Point2D(0, 0),
                    Id       = "id"
                });
                DistributionAssert.AreEqual(defaultStructure.StorageStructureArea, importedStructure.StorageStructureArea);
                DistributionAssert.AreEqual(defaultStructure.ThresholdHeightOpenWeir, importedStructure.ThresholdHeightOpenWeir);
                DistributionAssert.AreEqual(defaultStructure.InsideWaterLevelFailureConstruction, importedStructure.InsideWaterLevelFailureConstruction);
                Assert.AreEqual(defaultStructure.LevellingCount, importedStructure.LevellingCount);
                DistributionAssert.AreEqual(defaultStructure.AreaFlowApertures, importedStructure.AreaFlowApertures);
            });
            mocks.ReplayAll();

            ReferenceLine referenceLine      = CreateReferenceLine();
            var           structuresImporter = new StabilityPointStructuresImporter(importTarget,
                                                                                    referenceLine,
                                                                                    filePath,
                                                                                    messageProvider,
                                                                                    updateStrategy);

            // Call
            var    importResult = false;
            Action call         = () => importResult = structuresImporter.Import();

            // Assert
            TestHelper.AssertLogMessages(call, msgs =>
            {
                string[] messages = msgs.ToArray();
                Assert.AreEqual(12, messages.Length);

                const string structure = "'Coupure Den Oever (90k1)' (KUNST1)";

                Assert.AreEqual($"Geen definitie gevonden voor parameter 'KW_STERSTAB2' van kunstwerk {structure}. Er wordt een standaard waarde gebruikt.", messages[0]);
                Assert.AreEqual($"Geen definitie gevonden voor parameter 'KW_STERSTAB6' van kunstwerk {structure}. Er wordt een standaard waarde gebruikt.", messages[4]);
                Assert.AreEqual($"Geen definitie gevonden voor parameter 'KW_STERSTAB12' van kunstwerk {structure}. Er wordt een standaard waarde gebruikt.", messages[7]);
                Assert.AreEqual($"Geen definitie gevonden voor parameter 'KW_STERSTAB20' van kunstwerk {structure}. Er wordt een standaard waarde gebruikt.", messages[9]);
                Assert.AreEqual($"Geen definitie gevonden voor parameter 'KW_STERSTAB25' van kunstwerk {structure}. Er wordt een standaard waarde gebruikt.", messages[10]);
                // Don't care about the other messages.
            });
            Assert.IsTrue(importResult);
        }
        public void GivenInputWithStructure_WhenStructureNull_ThenSchematizationPropertiesSynedToDefaults()
        {
            // Given
            var structure = new TestStabilityPointStructure();
            var input     = new StabilityPointStructuresInput
            {
                Structure = structure
            };

            RoundedDouble         expectedVolumicWeightWater = input.VolumicWeightWater;
            LogNormalDistribution expectedDrainCoefficient   = input.DrainCoefficient;
            RoundedDouble         expectedFactorStormDurationOpenStructure = input.FactorStormDurationOpenStructure;
            double expectedFailureProbabilityStructureWithErosion          = input.FailureProbabilityStructureWithErosion;

            // Precondition
            AssertStabilityPointStructureInput(structure, input);

            // When
            input.Structure = null;

            // Then
            AssertAreEqual(expectedVolumicWeightWater, input.VolumicWeightWater);
            Assert.AreEqual(2, input.FactorStormDurationOpenStructure.NumberOfDecimalPlaces);
            Assert.AreEqual(expectedFactorStormDurationOpenStructure, input.FactorStormDurationOpenStructure,
                            input.FactorStormDurationOpenStructure.GetAccuracy());
            DistributionAssert.AreEqual(expectedDrainCoefficient, input.DrainCoefficient);
            Assert.AreEqual(expectedFailureProbabilityStructureWithErosion, input.FailureProbabilityStructureWithErosion);

            var expectedLevelCrestStructure = new NormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            var expectedThresholdHeightOpenWeir = new NormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            var expectedAreaFlowApertures = new LogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            var expectedConstructiveStrengthLinearLoadModel = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedConstructiveStrengthQuadraticLoadModel = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedStabilityLinearLoadModel = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedStabilityQuadraticLoadModel = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedFailureCollisionEnergy = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedShipMass = new VariationCoefficientNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedShipVelocity = new VariationCoefficientNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedBankWidth = new NormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            var expectedInsideWaterLevelFailureConstruction = new NormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            var expectedInsideWaterLevel = new NormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            var expectedFlowVelocityStructureClosable = new VariationCoefficientNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = (RoundedDouble)0.2
            };

            DistributionAssert.AreEqual(expectedLevelCrestStructure, input.LevelCrestStructure);
            DistributionAssert.AreEqual(expectedThresholdHeightOpenWeir, input.ThresholdHeightOpenWeir);
            DistributionAssert.AreEqual(expectedAreaFlowApertures, input.AreaFlowApertures);
            DistributionAssert.AreEqual(expectedConstructiveStrengthLinearLoadModel, input.ConstructiveStrengthLinearLoadModel);
            DistributionAssert.AreEqual(expectedConstructiveStrengthQuadraticLoadModel, input.ConstructiveStrengthQuadraticLoadModel);
            DistributionAssert.AreEqual(expectedStabilityLinearLoadModel, input.StabilityLinearLoadModel);
            DistributionAssert.AreEqual(expectedStabilityQuadraticLoadModel, input.StabilityQuadraticLoadModel);
            Assert.AreEqual(0, input.FailureProbabilityRepairClosure);
            DistributionAssert.AreEqual(expectedFailureCollisionEnergy, input.FailureCollisionEnergy);
            DistributionAssert.AreEqual(expectedShipMass, input.ShipMass);
            DistributionAssert.AreEqual(expectedShipVelocity, input.ShipVelocity);
            Assert.AreEqual(0, input.LevellingCount);
            Assert.AreEqual(0, input.ProbabilityCollisionSecondaryStructure);
            DistributionAssert.AreEqual(expectedBankWidth, input.BankWidth);
            DistributionAssert.AreEqual(expectedInsideWaterLevelFailureConstruction, input.InsideWaterLevelFailureConstruction);
            DistributionAssert.AreEqual(expectedInsideWaterLevel, input.InsideWaterLevel);
            DistributionAssert.AreEqual(expectedFlowVelocityStructureClosable, input.FlowVelocityStructureClosable);
            Assert.AreEqual(2, input.EvaluationLevel.NumberOfDecimalPlaces);
            AssertAreEqual(double.NaN, input.EvaluationLevel);
            Assert.AreEqual(2, input.VerticalDistance.NumberOfDecimalPlaces);
            AssertAreEqual(double.NaN, input.VerticalDistance);

            Assert.AreEqual(0, (int)input.InflowModelType);
            Assert.AreEqual(LoadSchematizationType.Linear, input.LoadSchematizationType);
        }
        public void Constructor_ExpectedValues()
        {
            // Call
            var input = new StabilityPointStructuresInput();

            // Assert
            Assert.IsInstanceOf <StructuresInputBase <StabilityPointStructure> >(input);

            AssertAreEqual(9.81, input.VolumicWeightWater);
            Assert.AreEqual(2, input.VolumicWeightWater.NumberOfDecimalPlaces);

            var expectedInsideWaterLevelFailureConstruction = new NormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            var expectedInsideWaterLevel = new NormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            var expectedDrainCoefficient = new LogNormalDistribution(2)
            {
                Mean = (RoundedDouble)1,
                StandardDeviation = (RoundedDouble)0.2
            };

            var expectedFlowVelocityStructureClosable = new VariationCoefficientNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = (RoundedDouble)0.2
            };

            var expectedLevelCrestStructure = new NormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            var expectedThresholdHeightOpenWeir = new NormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            var expectedAreaFlowApertures = new LogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            var expectedConstructiveStrengthLinearLoadModel = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedConstructiveStrengthQuadraticLoadModel = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedStabilityLinearLoadModel = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedStabilityQuadraticLoadModel = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedFailureCollisionEnergy = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedShipMass = new VariationCoefficientNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedShipVelocity = new VariationCoefficientNormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                CoefficientOfVariation = RoundedDouble.NaN
            };

            var expectedBankWidth = new NormalDistribution(2)
            {
                Mean = RoundedDouble.NaN,
                StandardDeviation = RoundedDouble.NaN
            };

            DistributionAssert.AreEqual(expectedInsideWaterLevelFailureConstruction, input.InsideWaterLevelFailureConstruction);
            DistributionAssert.AreEqual(expectedInsideWaterLevel, input.InsideWaterLevel);

            Assert.AreEqual(2, input.FactorStormDurationOpenStructure.NumberOfDecimalPlaces);
            Assert.AreEqual(1.0, input.FactorStormDurationOpenStructure, input.FactorStormDurationOpenStructure.GetAccuracy());
            DistributionAssert.AreEqual(expectedDrainCoefficient, input.DrainCoefficient);
            DistributionAssert.AreEqual(expectedFlowVelocityStructureClosable, input.FlowVelocityStructureClosable);

            DistributionAssert.AreEqual(expectedLevelCrestStructure, input.LevelCrestStructure);
            DistributionAssert.AreEqual(expectedThresholdHeightOpenWeir, input.ThresholdHeightOpenWeir);
            DistributionAssert.AreEqual(expectedAreaFlowApertures, input.AreaFlowApertures);
            DistributionAssert.AreEqual(expectedConstructiveStrengthLinearLoadModel, input.ConstructiveStrengthLinearLoadModel);
            DistributionAssert.AreEqual(expectedConstructiveStrengthQuadraticLoadModel, input.ConstructiveStrengthQuadraticLoadModel);
            DistributionAssert.AreEqual(expectedStabilityLinearLoadModel, input.StabilityLinearLoadModel);
            DistributionAssert.AreEqual(expectedStabilityQuadraticLoadModel, input.StabilityQuadraticLoadModel);
            Assert.AreEqual(0, input.FailureProbabilityRepairClosure);
            DistributionAssert.AreEqual(expectedFailureCollisionEnergy, input.FailureCollisionEnergy);
            DistributionAssert.AreEqual(expectedShipMass, input.ShipMass);
            DistributionAssert.AreEqual(expectedShipVelocity, input.ShipVelocity);
            Assert.AreEqual(0, input.LevellingCount);
            Assert.AreEqual(0, input.ProbabilityCollisionSecondaryStructure);
            DistributionAssert.AreEqual(expectedBankWidth, input.BankWidth);
            Assert.AreEqual(2, input.EvaluationLevel.NumberOfDecimalPlaces);
            AssertAreEqual(double.NaN, input.EvaluationLevel);
            Assert.AreEqual(2, input.VerticalDistance.NumberOfDecimalPlaces);
            AssertAreEqual(double.NaN, input.VerticalDistance);

            Assert.AreEqual(0, (int)input.InflowModelType);
            Assert.AreEqual(LoadSchematizationType.Linear, input.LoadSchematizationType);
        }
        private static void AssertStabilityPointStructureInput(StabilityPointStructure expectedStructure, StabilityPointStructuresInput input)
        {
            if (expectedStructure == null)
            {
                Assert.IsNull(input.Structure);
                var defaultInput = new StabilityPointStructuresInput();
                AssertAreEqual(defaultInput.StructureNormalOrientation, input.StructureNormalOrientation);

                DistributionAssert.AreEqual(defaultInput.AllowedLevelIncreaseStorage, input.AllowedLevelIncreaseStorage);
                DistributionAssert.AreEqual(defaultInput.AreaFlowApertures, input.AreaFlowApertures);
                DistributionAssert.AreEqual(defaultInput.BankWidth, input.BankWidth);
                DistributionAssert.AreEqual(defaultInput.ConstructiveStrengthLinearLoadModel, input.ConstructiveStrengthLinearLoadModel);
                DistributionAssert.AreEqual(defaultInput.ConstructiveStrengthQuadraticLoadModel, input.ConstructiveStrengthQuadraticLoadModel);
                DistributionAssert.AreEqual(defaultInput.CriticalOvertoppingDischarge, input.CriticalOvertoppingDischarge);
                AssertAreEqual(defaultInput.EvaluationLevel, input.EvaluationLevel);
                DistributionAssert.AreEqual(defaultInput.FailureCollisionEnergy, input.FailureCollisionEnergy);
                Assert.AreEqual(defaultInput.FailureProbabilityRepairClosure, input.FailureProbabilityRepairClosure);
                DistributionAssert.AreEqual(defaultInput.FlowVelocityStructureClosable, input.FlowVelocityStructureClosable);
                DistributionAssert.AreEqual(defaultInput.FlowWidthAtBottomProtection, input.FlowWidthAtBottomProtection);
                Assert.AreEqual(defaultInput.InflowModelType, input.InflowModelType);
                DistributionAssert.AreEqual(defaultInput.InsideWaterLevel, input.InsideWaterLevel);
                DistributionAssert.AreEqual(defaultInput.InsideWaterLevelFailureConstruction, input.InsideWaterLevelFailureConstruction);
                DistributionAssert.AreEqual(defaultInput.LevelCrestStructure, input.LevelCrestStructure);
                Assert.AreEqual(defaultInput.LevellingCount, input.LevellingCount);
                Assert.AreEqual(defaultInput.ProbabilityCollisionSecondaryStructure, input.ProbabilityCollisionSecondaryStructure);
                DistributionAssert.AreEqual(defaultInput.ShipMass, input.ShipMass);
                DistributionAssert.AreEqual(defaultInput.ShipVelocity, input.ShipVelocity);
                DistributionAssert.AreEqual(defaultInput.StabilityLinearLoadModel, input.StabilityLinearLoadModel);
                DistributionAssert.AreEqual(defaultInput.StabilityQuadraticLoadModel, input.StabilityQuadraticLoadModel);
                DistributionAssert.AreEqual(defaultInput.StorageStructureArea, input.StorageStructureArea);
                DistributionAssert.AreEqual(defaultInput.ThresholdHeightOpenWeir, input.ThresholdHeightOpenWeir);
                AssertAreEqual(defaultInput.VerticalDistance, input.VerticalDistance);
                DistributionAssert.AreEqual(defaultInput.WidthFlowApertures, input.WidthFlowApertures);
                Assert.AreEqual(defaultInput.StructureNormalOrientation, input.StructureNormalOrientation);
            }
            else
            {
                DistributionAssert.AreEqual(expectedStructure.AllowedLevelIncreaseStorage, input.AllowedLevelIncreaseStorage);
                DistributionAssert.AreEqual(expectedStructure.AreaFlowApertures, input.AreaFlowApertures);
                DistributionAssert.AreEqual(expectedStructure.BankWidth, input.BankWidth);
                DistributionAssert.AreEqual(expectedStructure.ConstructiveStrengthLinearLoadModel, input.ConstructiveStrengthLinearLoadModel);
                DistributionAssert.AreEqual(expectedStructure.ConstructiveStrengthQuadraticLoadModel, input.ConstructiveStrengthQuadraticLoadModel);
                DistributionAssert.AreEqual(expectedStructure.CriticalOvertoppingDischarge, input.CriticalOvertoppingDischarge);
                AssertAreEqual(expectedStructure.EvaluationLevel, input.EvaluationLevel);
                DistributionAssert.AreEqual(expectedStructure.FailureCollisionEnergy, input.FailureCollisionEnergy);
                Assert.AreEqual(expectedStructure.FailureProbabilityRepairClosure, input.FailureProbabilityRepairClosure);
                DistributionAssert.AreEqual(expectedStructure.FlowVelocityStructureClosable, input.FlowVelocityStructureClosable);
                DistributionAssert.AreEqual(expectedStructure.FlowWidthAtBottomProtection, input.FlowWidthAtBottomProtection);
                Assert.AreEqual(expectedStructure.InflowModelType, input.InflowModelType);
                DistributionAssert.AreEqual(expectedStructure.InsideWaterLevel, input.InsideWaterLevel);
                DistributionAssert.AreEqual(expectedStructure.InsideWaterLevelFailureConstruction, input.InsideWaterLevelFailureConstruction);
                DistributionAssert.AreEqual(expectedStructure.LevelCrestStructure, input.LevelCrestStructure);
                Assert.AreEqual(expectedStructure.LevellingCount, input.LevellingCount);
                Assert.AreEqual(expectedStructure.ProbabilityCollisionSecondaryStructure, input.ProbabilityCollisionSecondaryStructure);
                DistributionAssert.AreEqual(expectedStructure.ShipMass, input.ShipMass);
                DistributionAssert.AreEqual(expectedStructure.ShipVelocity, input.ShipVelocity);
                DistributionAssert.AreEqual(expectedStructure.StabilityLinearLoadModel, input.StabilityLinearLoadModel);
                DistributionAssert.AreEqual(expectedStructure.StabilityQuadraticLoadModel, input.StabilityQuadraticLoadModel);
                DistributionAssert.AreEqual(expectedStructure.StorageStructureArea, input.StorageStructureArea);
                DistributionAssert.AreEqual(expectedStructure.ThresholdHeightOpenWeir, input.ThresholdHeightOpenWeir);
                AssertAreEqual(expectedStructure.VerticalDistance, input.VerticalDistance);
                DistributionAssert.AreEqual(expectedStructure.WidthFlowApertures, input.WidthFlowApertures);
                AssertAreEqual(expectedStructure.StructureNormalOrientation, input.StructureNormalOrientation);
            }
        }