Exemple #1
0
        public void Validate_UseBreakWaterWithInvalidBreakWaterHeight_ErrorMessage(
            [Values(BreakWaterType.Wall, BreakWaterType.Caisson, BreakWaterType.Dam)]
            BreakWaterType type,
            [Values(double.NaN, double.NegativeInfinity, double.PositiveInfinity)]
            double height)
        {
            // Setup
            var breakWater = mockRepository.Stub <IUseBreakWater>();

            breakWater.UseBreakWater = true;
            breakWater.Stub(call => breakWater.BreakWater).Return(new BreakWater(type, height));
            mockRepository.ReplayAll();

            var rule = new UseBreakWaterRule(breakWater);

            // Call
            IEnumerable <string> messages = rule.Validate();

            string[] validationMessages = messages.ToArray();

            // Assert
            Assert.AreEqual(1, validationMessages.Length);
            const string expectedMessage = "De waarde voor 'hoogte' van de dam moet een concreet getal zijn.";

            StringAssert.StartsWith(expectedMessage, validationMessages[0]);
            mockRepository.VerifyAll();
        }
        public void ReadWaveReduction_WithConfigurationWithMissingParameter_MissingParameterUnchanged(
            [Values(0, 1, 2, 3)] int parameterNotSet)
        {
            // Setup
            const bool useForeshoreProfile = false;
            const bool useBreakWater = false;
            const double height = 2.55;
            const BreakWaterType breakWaterType = BreakWaterType.Dam;

            const bool newUseForeshoreProfile = true;
            const bool newUseBreakWater = true;
            const double newHeight = 11.1;
            const ConfigurationBreakWaterType newBreakWaterType = ConfigurationBreakWaterType.Wall;
            const BreakWaterType expectedNewBreakWaterType = BreakWaterType.Wall;

            var testInput = new TestInputWithForeshoreProfileAndBreakWater(new BreakWater(breakWaterType, height))
            {
                UseBreakWater = useBreakWater,
                UseForeshore = useForeshoreProfile
            };

            var waveReductionConfiguration = new WaveReductionConfiguration();
            if (parameterNotSet != 0)
            {
                waveReductionConfiguration.UseForeshoreProfile = newUseForeshoreProfile;
            }

            if (parameterNotSet != 1)
            {
                waveReductionConfiguration.UseBreakWater = newUseBreakWater;
            }

            if (parameterNotSet != 2)
            {
                waveReductionConfiguration.BreakWaterHeight = newHeight;
            }

            if (parameterNotSet != 3)
            {
                waveReductionConfiguration.BreakWaterType = newBreakWaterType;
            }

            string filePath = Path.Combine(readerPath, "validConfiguration.xml");

            var calculationGroup = new CalculationGroup();

            var importer = new CalculationConfigurationImporter(filePath, calculationGroup);

            // Call
            importer.PublicReadWaveReductionParameters(waveReductionConfiguration, testInput);

            // Assert
            Assert.AreEqual(testInput.UseForeshore, parameterNotSet == 0 ? useForeshoreProfile : newUseForeshoreProfile);
            Assert.AreEqual(testInput.UseBreakWater, parameterNotSet == 1 ? useBreakWater : newUseBreakWater);
            Assert.AreEqual(testInput.BreakWater.Height, parameterNotSet == 2 ? height : newHeight, testInput.BreakWater.Height.GetAccuracy());
            Assert.AreEqual(testInput.BreakWater.Type, parameterNotSet == 3 ? breakWaterType : expectedNewBreakWaterType);
        }
Exemple #3
0
        public void Calculate_Always_InputPropertiesCorrectlySentToCalculator(BreakWaterType breakWaterType)
        {
            // Setup
            IAssessmentSection assessmentSection = CreateAssessmentSectionWithHydraulicBoundaryOutput();
            WaveImpactAsphaltCoverWaveConditionsCalculation calculation = GetValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First());

            calculation.InputParameters.BreakWater.Type = breakWaterType;

            var waveImpactAsphaltCoverFailureMechanism = new WaveImpactAsphaltCoverFailureMechanism();

            var calculator = new TestWaveConditionsCosineCalculator();

            var mockRepository    = new MockRepository();
            var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>();

            calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(null))
            .IgnoreArguments()
            .Return(calculator)
            .Repeat
            .Times(3);
            mockRepository.ReplayAll();

            using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
            {
                // Call
                new WaveImpactAsphaltCoverWaveConditionsCalculationService().Calculate(
                    calculation,
                    assessmentSection,
                    waveImpactAsphaltCoverFailureMechanism.GeneralInput);

                // Assert
                WaveConditionsCosineCalculationInput[] waveConditionsInputs = calculator.ReceivedInputs.ToArray();
                Assert.AreEqual(3, waveConditionsInputs.Length);

                var waterLevelIndex = 0;
                foreach (WaveConditionsCosineCalculationInput actualInput in waveConditionsInputs)
                {
                    GeneralWaveConditionsInput generalInput = waveImpactAsphaltCoverFailureMechanism.GeneralInput;

                    WaveConditionsInput input = calculation.InputParameters;
                    var expectedInput         = new WaveConditionsCosineCalculationInput(1,
                                                                                         input.Orientation,
                                                                                         input.HydraulicBoundaryLocation.Id,
                                                                                         assessmentSection.FailureMechanismContribution.MaximumAllowableFloodingProbability,
                                                                                         input.ForeshoreProfile.Geometry.Select(c => new HydraRingForelandPoint(c.X, c.Y)),
                                                                                         new HydraRingBreakWater(BreakWaterTypeHelper.GetHydraRingBreakWaterType(breakWaterType), input.BreakWater.Height),
                                                                                         GetWaterLevels(calculation, assessmentSection).ElementAt(waterLevelIndex++),
                                                                                         generalInput.A,
                                                                                         generalInput.B,
                                                                                         generalInput.C);

                    HydraRingDataEqualityHelper.AreEqual(expectedInput, actualInput);
                }
            }

            mockRepository.VerifyAll();
        }
        public void ForeshoreProfile_SetNewValue_InputSyncedAccordingly(
            [Values(true, false)] bool withBreakWater,
            [Values(true, false)] bool withValidForeshore)
        {
            // Setup
            var                       input = new SimpleStructuresInput();
            BreakWaterType            originalBreakWaterType            = input.BreakWater.Type;
            RoundedDouble             originalBreakWaterHeight          = input.BreakWater.Height;
            HydraulicBoundaryLocation originalHydraulicBoundaryLocation = input.HydraulicBoundaryLocation;

            var foreshoreGeometry = new List <Point2D>
            {
                new Point2D(2.2, 3.3)
            };

            if (withValidForeshore)
            {
                foreshoreGeometry.Add(new Point2D(4.4, 5.5));
            }

            BreakWater breakWater = null;

            if (withBreakWater)
            {
                const BreakWaterType nonDefaultBreakWaterType   = BreakWaterType.Wall;
                const double         nonDefaultBreakWaterHeight = 5.5;

                // Precondition
                Assert.AreNotEqual(nonDefaultBreakWaterType, input.BreakWater.Type);
                Assert.AreNotEqual(nonDefaultBreakWaterHeight, input.BreakWater.Height);

                breakWater = new BreakWater(nonDefaultBreakWaterType, nonDefaultBreakWaterHeight);
            }

            const double orientation      = 96;
            var          foreshoreProfile = new ForeshoreProfile(new Point2D(0, 0),
                                                                 foreshoreGeometry.ToArray(),
                                                                 breakWater,
                                                                 new ForeshoreProfile.ConstructionProperties
            {
                Id          = "id",
                Orientation = orientation
            });

            // Call
            input.ForeshoreProfile = foreshoreProfile;

            // Assert
            Assert.AreSame(foreshoreProfile, input.ForeshoreProfile);
            Assert.AreEqual(withBreakWater, input.UseBreakWater);
            Assert.AreEqual(withBreakWater ? foreshoreProfile.BreakWater.Type : originalBreakWaterType, input.BreakWater.Type);
            Assert.AreEqual(withBreakWater ? foreshoreProfile.BreakWater.Height : originalBreakWaterHeight, input.BreakWater.Height);
            Assert.AreEqual(withValidForeshore, input.UseForeshore);
            CollectionAssert.AreEqual(foreshoreProfile.Geometry, input.ForeshoreGeometry);
            Assert.AreSame(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation);
        }
        public void ConvertFrom_BreakWaterType_ReturnExpectedBreakWaterType(BreakWaterType value,
                                                                            ConfigurationBreakWaterType expectedResult)
        {
            // Setup
            var converter = new ConfigurationBreakWaterTypeConverter();

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

            // Assert
            Assert.AreEqual(expectedResult, result);
        }
        public void ConvertTo_VariousCases_ReturnExpectedText(ConfigurationBreakWaterType value,
                                                              BreakWaterType expectedResult)
        {
            // Setup
            var converter = new ConfigurationBreakWaterTypeConverter();

            // Call
            object result = converter.ConvertTo(value, typeof(BreakWaterType));

            // Assert
            Assert.AreEqual(expectedResult, result);
        }
Exemple #7
0
        public void Properties_Height_ReturnsExpectedValue()
        {
            // Setup
            const BreakWaterType type   = BreakWaterType.Caisson;
            const double         height = 100.10;
            var breakWater = new BreakWater(type, height);

            // Call
            breakWater.Height = (RoundedDouble)10.00;

            // Assert
            Assert.AreEqual(10.0, breakWater.Height.Value);
        }
Exemple #8
0
        public void Properties_Type_ReturnsExpectedValue(BreakWaterType newType)
        {
            // Setup
            const BreakWaterType type   = BreakWaterType.Caisson;
            const double         height = 100.1;
            var breakWater = new BreakWater(type, height);

            // Call
            breakWater.Type = newType;

            // Assert
            Assert.AreEqual(newType, breakWater.Type);
        }
Exemple #9
0
        public void Constructor_Always_ExpectedValues()
        {
            // Setup
            const BreakWaterType type   = BreakWaterType.Caisson;
            const double         height = 100.1;

            // Call
            var breakWater = new BreakWater(type, height);

            // Assert
            Assert.IsInstanceOf <ICloneable>(breakWater);
            Assert.AreEqual(type, breakWater.Type);
            Assert.AreEqual(height, breakWater.Height, 1e-6);
            Assert.AreEqual(2, breakWater.Height.NumberOfDecimalPlaces);
        }
Exemple #10
0
        public void Create_WithBreakWater_ReturnEntity(BreakWaterType type, double height)
        {
            // Setup
            int order       = new Random(42).Next();
            var dikeProfile = new DikeProfile(new Point2D(1234.4567, 5678.432),
                                              new[]
            {
                new RoughnessPoint(new Point2D(-6.6, -3.3), 0.75),
                new RoughnessPoint(new Point2D(4.4, 5.5), 0.75)
            },
                                              new[]
            {
                new Point2D(-12.12, -13.13),
                new Point2D(-6.6, -3.3)
            },
                                              new BreakWater(type, height),
                                              new DikeProfile.ConstructionProperties
            {
                Id          = "no_breakwater",
                Name        = "Dike profile without break water.",
                DikeHeight  = 98.76,
                Orientation = 76.54,
                X0          = -12.34
            });
            var registry = new PersistenceRegistry();

            // Call
            DikeProfileEntity entity = dikeProfile.Create(registry, order);

            // Assert
            Assert.AreEqual(dikeProfile.WorldReferencePoint.X, entity.X);
            Assert.AreEqual(dikeProfile.WorldReferencePoint.Y, entity.Y);
            Assert.AreEqual(dikeProfile.X0, entity.X0);
            Assert.AreEqual(order, entity.Order);
            string convertedDikeGeometry = new RoughnessPointCollectionXmlSerializer().ToXml(dikeProfile.DikeGeometry);

            Assert.AreEqual(convertedDikeGeometry, entity.DikeGeometryXml);
            string convertedForeshoreGeometry = new Point2DCollectionXmlSerializer().ToXml(dikeProfile.ForeshoreGeometry);

            Assert.AreEqual(convertedForeshoreGeometry, entity.ForeshoreXml);
            Assert.AreEqual(dikeProfile.Orientation.Value, entity.Orientation);
            Assert.AreEqual(dikeProfile.DikeHeight.Value, entity.DikeHeight);
            Assert.AreEqual(dikeProfile.Id, entity.Id);
            Assert.AreEqual(dikeProfile.Name, entity.Name);

            Assert.AreEqual((byte)type, entity.BreakWaterType);
            Assert.AreEqual(height, entity.BreakWaterHeight);
        }
Exemple #11
0
        public void ParseBreakWater_DoesNotUse_ReturnNull(BreakWaterType breakWaterType)
        {
            // Setup
            var mockRepository = new MockRepository();
            var breakWater     = mockRepository.Stub <IUseBreakWater>();

            breakWater.UseBreakWater = false;
            mockRepository.ReplayAll();

            // Call
            HydraRingBreakWater parsedBreakWater = HydraRingInputParser.ParseBreakWater(breakWater);

            // Assert
            Assert.IsNull(parsedBreakWater);
            mockRepository.VerifyAll();
        }
        public void Create_WithBreakWater_ReturnsForeshoreProfileWithBreakWaterPropertiesSet()
        {
            // Setup
            double height = new Random(21).NextDouble();
            const BreakWaterType breakWaterType = BreakWaterType.Caisson;
            var foreshoreProfile = new TestForeshoreProfile(new BreakWater(breakWaterType, height));
            var registry         = new PersistenceRegistry();

            // Call
            ForeshoreProfileEntity entity = foreshoreProfile.Create(registry, 0);

            // Assert
            Assert.IsNotNull(entity);
            Assert.AreEqual((int)breakWaterType, entity.BreakWaterType);
            Assert.AreEqual(height, entity.BreakWaterHeight, foreshoreProfile.BreakWater.Height.GetAccuracy());
        }
Exemple #13
0
        public void Foreshore_SetNullValue_InputSyncedToDefaults()
        {
            // Setup
            var                       input = new WaveConditionsInput();
            BreakWaterType            originalBreakWaterType            = input.BreakWater.Type;
            RoundedDouble             originalBreakWaterHeight          = input.BreakWater.Height;
            HydraulicBoundaryLocation originalHydraulicBoundaryLocation = input.HydraulicBoundaryLocation;

            var foreshoreProfile = new ForeshoreProfile(new Point2D(0, 0),
                                                        new[]
            {
                new Point2D(3.3, 4.4),
                new Point2D(5.5, 6.6)
            },
                                                        new BreakWater(BreakWaterType.Caisson, 2.2),
                                                        new ForeshoreProfile.ConstructionProperties
            {
                Id          = "id",
                Orientation = 96
            });

            input.ForeshoreProfile = foreshoreProfile;

            // Precondition
            Assert.IsTrue(input.IsForeshoreProfileInputSynchronized);
            Assert.AreSame(foreshoreProfile, input.ForeshoreProfile);
            Assert.IsTrue(input.UseBreakWater);
            Assert.AreNotEqual(originalBreakWaterType, input.BreakWater.Type);
            Assert.AreNotEqual(originalBreakWaterHeight, input.BreakWater.Height);
            Assert.IsTrue(input.UseForeshore);
            CollectionAssert.IsNotEmpty(input.ForeshoreGeometry);
            Assert.AreEqual(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation);

            // Call
            input.ForeshoreProfile = null;

            // Assert
            Assert.IsFalse(input.IsForeshoreProfileInputSynchronized);
            Assert.IsFalse(input.UseBreakWater);
            Assert.AreEqual(originalBreakWaterType, input.BreakWater.Type);
            Assert.AreEqual(originalBreakWaterHeight, input.BreakWater.Height);
            Assert.IsFalse(input.UseForeshore);
            CollectionAssert.IsEmpty(input.ForeshoreGeometry);
            Assert.AreEqual(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation);
            Assert.AreEqual(foreshoreProfile.Orientation, input.Orientation, input.Orientation.GetAccuracy());
            Assert.AreEqual(2, input.Orientation.NumberOfDecimalPlaces);
        }
        public void Read_WithGeometryAndBreakWaterTypeAndValues_CompleteForeshoreProfile()
        {
            // Setup
            const string         name           = "testName";
            const string         id             = "testId";
            var                  random         = new Random(21);
            int                  order          = random.Next();
            double               orientation    = random.NextDouble();
            double               x0             = random.NextDouble();
            double               height         = random.NextDouble();
            const BreakWaterType breakWaterType = BreakWaterType.Wall;

            var points = new[]
            {
                new Point2D(0, 0)
            };
            string pointXml = new Point2DCollectionXmlSerializer().ToXml(points);
            var    entity   = new ForeshoreProfileEntity
            {
                Order            = order,
                Id               = id,
                Name             = name,
                Orientation      = orientation,
                X0               = x0,
                BreakWaterType   = Convert.ToByte(breakWaterType),
                BreakWaterHeight = height,
                GeometryXml      = pointXml
            };

            var readConversionCollector = new ReadConversionCollector();

            // Call
            ForeshoreProfile foreshoreProfile = entity.Read(readConversionCollector);

            // Assert
            Assert.IsNotNull(foreshoreProfile);
            Assert.AreEqual(name, foreshoreProfile.Name);
            Assert.AreEqual(order, entity.Order);
            Assert.AreEqual(id, foreshoreProfile.Id);
            Assert.AreEqual(name, entity.Name);
            Assert.AreEqual(orientation, foreshoreProfile.Orientation, foreshoreProfile.Orientation.GetAccuracy());
            Assert.AreEqual(x0, entity.X0);
            Assert.AreEqual(breakWaterType, foreshoreProfile.BreakWater.Type);
            Assert.IsTrue(foreshoreProfile.HasBreakWater);
            CollectionAssert.AreEqual(points, foreshoreProfile.Geometry);
        }
Exemple #15
0
        /// <summary>
        /// Gets the Hydra-Ring integer value corresponding to <paramref name="type"/>.
        /// </summary>
        /// <param name="type">The <see cref="BreakWaterType"/> to get the Hydra-Ring value for.</param>
        /// <returns>A Hydra-Ring specific integer value.</returns>
        public static int GetHydraRingBreakWaterType(BreakWaterType type)
        {
            switch (type)
            {
            case BreakWaterType.Caisson:
                return(1);

            case BreakWaterType.Wall:
                return(2);

            case BreakWaterType.Dam:
                return(3);

            default:
                return(0);
            }
        }
Exemple #16
0
        public void Validate_ValidBreakWaterHeight_NoErrorMessage(BreakWaterType type)
        {
            // Setup
            var breakWater = mockRepository.Stub <IUseBreakWater>();

            breakWater.UseBreakWater = true;
            breakWater.Stub(call => breakWater.BreakWater).Return(new BreakWater(type, 5.0));
            mockRepository.ReplayAll();

            var rule = new UseBreakWaterRule(breakWater);

            // Call
            IEnumerable <string> message = rule.Validate();

            // Assert
            CollectionAssert.IsEmpty(message);
            mockRepository.VerifyAll();
        }
Exemple #17
0
        /// <summary>
        /// Converts <paramref name="type"/> into an integer value to be used by Hydra-Ring.
        /// </summary>
        /// <param name="type">The <see cref="BreakWaterType"/> to convert.</param>
        /// <returns>The integer value to be used by Hydra-Ring.</returns>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="type"/> is an invalid value.</exception>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="type"/> is a valid value, but unsupported.</exception>
        private static int ConvertBreakWaterType(BreakWaterType type)
        {
            if (!Enum.IsDefined(type.GetType(), type))
            {
                throw new InvalidEnumArgumentException(nameof(type), (int)type, type.GetType());
            }

            switch (type)
            {
            case BreakWaterType.Caisson:
                return(1);

            case BreakWaterType.Wall:
                return(2);

            case BreakWaterType.Dam:
                return(3);

            default:
                throw new NotSupportedException();
            }
        }
Exemple #18
0
        public void Validate_DoesNotUseBreakWaterWithInvalidBreakWaterHeight_NoErrorMessage(
            [Values(BreakWaterType.Wall, BreakWaterType.Caisson, BreakWaterType.Dam)]
            BreakWaterType type,
            [Values(double.NaN, double.NegativeInfinity, double.PositiveInfinity)]
            double height)
        {
            // Setup
            var breakWater = mockRepository.Stub <IUseBreakWater>();

            breakWater.UseBreakWater = false;
            breakWater.Stub(call => breakWater.BreakWater).Return(new BreakWater(type, height));
            mockRepository.ReplayAll();

            var rule = new UseBreakWaterRule(breakWater);

            // Call
            IEnumerable <string> message = rule.Validate();

            // Assert
            CollectionAssert.IsEmpty(message);
            mockRepository.VerifyAll();
        }
Exemple #19
0
        public void ParseBreakWater_Use_ReturnHydraRingBreakWater(BreakWaterType breakWaterType)
        {
            // Setup
            var    random           = new Random(22);
            double breakWaterHeight = random.NextDouble();

            var mockRepository = new MockRepository();
            var breakWater     = mockRepository.Stub <IUseBreakWater>();

            breakWater.UseBreakWater = true;
            var expectedBreakWater = new BreakWater(breakWaterType, breakWaterHeight);

            breakWater.Stub(call => call.BreakWater).Return(expectedBreakWater);
            mockRepository.ReplayAll();

            // Call
            HydraRingBreakWater parsedBreakWater = HydraRingInputParser.ParseBreakWater(breakWater);

            // Assert
            Assert.AreEqual(BreakWaterTypeHelper.GetHydraRingBreakWaterType(breakWaterType), parsedBreakWater.Type);
            Assert.AreEqual(expectedBreakWater.Height, parsedBreakWater.Height, expectedBreakWater.Height.GetAccuracy());
            mockRepository.VerifyAll();
        }
        public void Calculate_VariousCalculationsWithBreakWater_InputPropertiesCorrectlySentToCalculator(BreakWaterType breakWaterType)
        {
            // Setup
            var failureMechanism = new HeightStructuresFailureMechanism();

            var mockRepository = new MockRepository();
            IAssessmentSection assessmentSection = AssessmentSectionTestHelper.CreateAssessmentSectionStub(failureMechanism, mockRepository);

            var calculator        = new TestStructuresCalculator <StructuresOvertoppingCalculationInput>();
            var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>();

            calculatorFactory.Expect(cf => cf.CreateStructuresCalculator <StructuresOvertoppingCalculationInput>(null))
            .IgnoreArguments()
            .Return(calculator);
            mockRepository.ReplayAll();

            var calculation = new TestHeightStructuresCalculationScenario
            {
                InputParameters =
                {
                    HydraulicBoundaryLocation = assessmentSection.HydraulicBoundaryDatabase.Locations.First(hl => hl.Id == 1300001),
                    ForeshoreProfile          = new TestForeshoreProfile(true)
                    {
                        BreakWater            =
                        {
                            Type              = breakWaterType
                        }
                    }
                }
            };

            using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
            {
                // Call
                new HeightStructuresCalculationService().Calculate(calculation,
                                                                   failureMechanism.GeneralInput,
                                                                   CreateCalculationSettings());

                // Assert
                StructuresOvertoppingCalculationInput[] overtoppingCalculationInputs = calculator.ReceivedInputs.ToArray();
                Assert.AreEqual(1, overtoppingCalculationInputs.Length);

                GeneralHeightStructuresInput generalInput = failureMechanism.GeneralInput;
                HeightStructuresInput        input        = calculation.InputParameters;
                var expectedInput = new StructuresOvertoppingCalculationInput(
                    1300001,
                    input.StructureNormalOrientation,
                    input.ForeshoreGeometry.Select(c => new HydraRingForelandPoint(c.X, c.Y)),
                    new HydraRingBreakWater(BreakWaterTypeHelper.GetHydraRingBreakWaterType(breakWaterType), input.BreakWater.Height),
                    generalInput.GravitationalAcceleration,
                    generalInput.ModelFactorOvertoppingFlow.Mean, generalInput.ModelFactorOvertoppingFlow.StandardDeviation,
                    input.LevelCrestStructure.Mean, input.LevelCrestStructure.StandardDeviation,
                    input.StructureNormalOrientation,
                    input.ModelFactorSuperCriticalFlow.Mean, input.ModelFactorSuperCriticalFlow.StandardDeviation,
                    input.AllowedLevelIncreaseStorage.Mean, input.AllowedLevelIncreaseStorage.StandardDeviation,
                    generalInput.ModelFactorStorageVolume.Mean, generalInput.ModelFactorStorageVolume.StandardDeviation,
                    input.StorageStructureArea.Mean, input.StorageStructureArea.CoefficientOfVariation,
                    generalInput.ModelFactorInflowVolume,
                    input.FlowWidthAtBottomProtection.Mean, input.FlowWidthAtBottomProtection.StandardDeviation,
                    input.CriticalOvertoppingDischarge.Mean, input.CriticalOvertoppingDischarge.CoefficientOfVariation,
                    input.FailureProbabilityStructureWithErosion,
                    input.WidthFlowApertures.Mean, input.WidthFlowApertures.StandardDeviation,
                    input.DeviationWaveDirection,
                    input.StormDuration.Mean, input.StormDuration.CoefficientOfVariation);

                StructuresOvertoppingCalculationInput actualInput = overtoppingCalculationInputs[0];
                HydraRingDataEqualityHelper.AreEqual(expectedInput, actualInput);
                Assert.IsFalse(calculator.IsCanceled);
            }

            mockRepository.VerifyAll();
        }
        public void Read_EntityWithForeshoreProfile_ReturnCalculation(bool flagUsage, BreakWaterType type, int randomSeed)
        {
            // Setup
            var random = new Random(randomSeed);

            double breakWaterHeight = random.NextDouble();
            var    points           = new[]
            {
                new Point2D(0, 0)
            };
            string pointXml        = new Point2DCollectionXmlSerializer().ToXml(points);
            var    foreshoreEntity = new ForeshoreProfileEntity
            {
                Id = "id",
                BreakWaterHeight = breakWaterHeight,
                BreakWaterType   = Convert.ToByte(type),
                GeometryXml      = pointXml
            };

            var entity = new HeightStructuresCalculationEntity
            {
                UseForeshore           = Convert.ToByte(flagUsage),
                UseBreakWater          = Convert.ToByte(!flagUsage),
                ForeshoreProfileEntity = foreshoreEntity,
                BreakWaterType         = Convert.ToByte(type),
                BreakWaterHeight       = breakWaterHeight,
                ScenarioContribution   = 0
            };

            var collector = new ReadConversionCollector();

            // Call
            StructuresCalculationScenario <HeightStructuresInput> calculation = entity.Read(collector);

            // Assert
            HeightStructuresInput input = calculation.InputParameters;

            Assert.AreEqual(flagUsage, input.UseForeshore);
            Assert.AreEqual(!flagUsage, input.UseBreakWater);
            Assert.AreEqual(type, input.BreakWater.Type);
            Assert.AreEqual(breakWaterHeight, input.BreakWater.Height, input.BreakWater.Height.GetAccuracy());
            CollectionAssert.AreEqual(points, input.ForeshoreProfile.Geometry);
            Assert.IsNotNull(input.ForeshoreProfile);
        }
Exemple #22
0
 public void BreakWaterType_ChangeToEqualValue_NoNotificationsAndOutputNotCleared(BreakWaterType breakWaterType)
 {
     // Call
     AssertPropertyNotChanged(
         row =>
     {
         breakWaterType     = row.BreakWaterType;
         row.BreakWaterType = row.BreakWaterType;
     },
         calculation =>
     {
         // Assert
         Assert.NotNull(breakWaterType);
         Assert.AreEqual(breakWaterType, calculation.InputParameters.BreakWater.Type);
     });
 }
Exemple #23
0
        public void BreakWaterType_AlwaysOnChange_NotifyObserverAndCalculationPropertyChanged(BreakWaterType breakWaterType, BreakWaterType newBreakWaterType)
        {
            // Setup
            var calculation = new StructuresCalculationScenario <HeightStructuresInput>
            {
                InputParameters =
                {
                    BreakWater =
                    {
                        Type   = breakWaterType
                    }
                }
            };

            // Call & Assert
            SetPropertyAndVerifyNotificationsAndOutputForCalculation(row => row.BreakWaterType = newBreakWaterType, calculation);
        }
Exemple #24
0
 /// <summary>
 /// Creates a new instance of <see cref="BreakWater"/>.
 /// </summary>
 /// <param name="type">The break water type.</param>
 /// <param name="height">The break water height.</param>
 public BreakWater(BreakWaterType type, double height)
 {
     Type        = type;
     this.height = new RoundedDouble(2, height);
 }
        public void Run_Always_InputPropertiesCorrectlySentToService(BreakWaterType breakWaterType)
        {
            // Setup
            AssessmentSectionStub assessmentSection = CreateAssessmentSection();

            ConfigureAssessmentSectionWithHydraulicBoundaryOutput(assessmentSection);

            GrassCoverErosionOutwardsWaveConditionsCalculation calculation = CreateValidCalculation(assessmentSection.HydraulicBoundaryDatabase.Locations.First());

            calculation.InputParameters.BreakWater.Type = breakWaterType;

            var failureMechanism          = new GrassCoverErosionOutwardsFailureMechanism();
            CalculatableActivity activity = GrassCoverErosionOutwardsCalculationActivityFactory.CreateWaveConditionsCalculationActivity(calculation,
                                                                                                                                        failureMechanism,
                                                                                                                                        assessmentSection);

            var waveConditionsCosineCalculator = new TestWaveConditionsCosineCalculator();

            RoundedDouble[] waterLevels     = GetWaterLevels(calculation, assessmentSection).ToArray();
            int             nrOfCalculators = GetNrOfCalculators(calculation, assessmentSection);

            var mockRepository    = new MockRepository();
            var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>();

            calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(null))
            .IgnoreArguments()
            .Return(waveConditionsCosineCalculator)
            .Repeat
            .Times(nrOfCalculators);
            mockRepository.ReplayAll();

            using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
            {
                // Call
                activity.Run();

                // Assert
                WaveConditionsCosineCalculationInput[] waveConditionsInputs = waveConditionsCosineCalculator.ReceivedInputs.ToArray();
                Assert.AreEqual(nrOfCalculators, waveConditionsInputs.Length);

                WaveConditionsInput input = calculation.InputParameters;
                double targetProbability  = assessmentSection.FailureMechanismContribution.MaximumAllowableFloodingProbability;

                var waterLevelIndex = 0;
                GeneralGrassCoverErosionOutwardsInput generalInput = failureMechanism.GeneralInput;
                for (var i = 0; i < waveConditionsInputs.Length / 2; i++)
                {
                    var expectedInput = new WaveConditionsCosineCalculationInput(1,
                                                                                 input.Orientation,
                                                                                 input.HydraulicBoundaryLocation.Id,
                                                                                 targetProbability,
                                                                                 input.ForeshoreProfile.Geometry.Select(c => new HydraRingForelandPoint(c.X, c.Y)),
                                                                                 new HydraRingBreakWater(BreakWaterTypeHelper.GetHydraRingBreakWaterType(breakWaterType), input.BreakWater.Height),
                                                                                 waterLevels[waterLevelIndex++],
                                                                                 generalInput.GeneralWaveRunUpWaveConditionsInput.A,
                                                                                 generalInput.GeneralWaveRunUpWaveConditionsInput.B,
                                                                                 generalInput.GeneralWaveRunUpWaveConditionsInput.C);

                    HydraRingDataEqualityHelper.AreEqual(expectedInput, waveConditionsInputs[i]);
                }

                waterLevelIndex = 0;
                for (int i = waveConditionsInputs.Length / 2; i < waveConditionsInputs.Length; i++)
                {
                    var expectedInput = new WaveConditionsCosineCalculationInput(1,
                                                                                 input.Orientation,
                                                                                 input.HydraulicBoundaryLocation.Id,
                                                                                 targetProbability,
                                                                                 input.ForeshoreProfile.Geometry.Select(c => new HydraRingForelandPoint(c.X, c.Y)),
                                                                                 new HydraRingBreakWater(BreakWaterTypeHelper.GetHydraRingBreakWaterType(breakWaterType), input.BreakWater.Height),
                                                                                 waterLevels[waterLevelIndex++],
                                                                                 generalInput.GeneralWaveImpactWaveConditionsInput.A,
                                                                                 generalInput.GeneralWaveImpactWaveConditionsInput.B,
                                                                                 generalInput.GeneralWaveImpactWaveConditionsInput.C);

                    HydraRingDataEqualityHelper.AreEqual(expectedInput, waveConditionsInputs[i]);
                }
            }

            mockRepository.VerifyAll();
        }
        public void Calculate_WithBreakWater_StartsCalculationWithRightParameters(BreakWaterType breakWaterType)
        {
            // Setup
            var          waterLevel        = (RoundedDouble)4.20;
            var          a                 = (RoundedDouble)1.0;
            var          b                 = (RoundedDouble)0.8;
            var          c                 = (RoundedDouble)0.4;
            const double targetProbability = 0.2;
            var          input             = new WaveConditionsInput
            {
                HydraulicBoundaryLocation = new TestHydraulicBoundaryLocation(),
                ForeshoreProfile          = new TestForeshoreProfile(true),
                UpperBoundaryRevetment    = (RoundedDouble)4,
                LowerBoundaryRevetment    = (RoundedDouble)3,
                StepSize      = WaveConditionsInputStepSize.Two,
                UseBreakWater = true,
                UseForeshore  = true,
                Orientation   = (RoundedDouble)0,
                BreakWater    =
                {
                    Type = breakWaterType
                }
            };

            var calculator = new TestWaveConditionsCosineCalculator();

            RoundedDouble[] waterLevels = input.GetWaterLevels(waterLevel).ToArray();

            int nrOfCalculators = waterLevels.Length;

            var mockRepository    = new MockRepository();
            var calculatorFactory = mockRepository.StrictMock <IHydraRingCalculatorFactory>();

            calculatorFactory.Expect(cf => cf.CreateWaveConditionsCosineCalculator(null))
            .IgnoreArguments()
            .Return(calculator)
            .Repeat
            .Times(nrOfCalculators);
            mockRepository.ReplayAll();

            using (new HydraRingCalculatorFactoryConfig(calculatorFactory))
            {
                // Call
                new TestWaveConditionsCalculationService().PublicCalculate(a,
                                                                           b,
                                                                           c,
                                                                           targetProbability,
                                                                           input,
                                                                           waterLevel,
                                                                           GetValidHydraulicBoundaryDatabase());

                // Assert
                for (var i = 0; i < nrOfCalculators; i++)
                {
                    WaveConditionsCosineCalculationInput expectedInput = CreateInput(waterLevels[i], a, b, c, targetProbability, input, true, true);
                    HydraRingDataEqualityHelper.AreEqual(expectedInput, calculator.ReceivedInputs.ElementAt(i));
                }
            }

            mockRepository.VerifyAll();
        }
        public void ReadWaveReduction_DifferentScenarios_CorrectParametersSet(bool useForeshoreProfile, bool useBreakWater, double height, ConfigurationBreakWaterType type, BreakWaterType expectedType)
        {
            // Setup
            var testInput = new TestInputWithForeshoreProfileAndBreakWater(new BreakWater(BreakWaterType.Caisson, 0.0));

            string filePath = Path.Combine(readerPath, "validConfiguration.xml");

            var calculationGroup = new CalculationGroup();

            var importer = new CalculationConfigurationImporter(filePath, calculationGroup);

            var waveReductionConfiguration = new WaveReductionConfiguration
            {
                UseForeshoreProfile = useForeshoreProfile,
                UseBreakWater = useBreakWater,
                BreakWaterHeight = height,
                BreakWaterType = type
            };

            // Call
            importer.PublicReadWaveReductionParameters(waveReductionConfiguration, testInput);

            // Assert
            Assert.AreEqual(testInput.UseForeshore, useForeshoreProfile);
            Assert.AreEqual(testInput.UseBreakWater, useBreakWater);
            Assert.AreEqual(testInput.BreakWater.Height, height, testInput.BreakWater.Height.GetAccuracy());
            Assert.AreEqual(testInput.BreakWater.Type, expectedType);
        }
Exemple #28
0
        public void Read_DikeProfileEntityWithBreakWater_ReturnDikeProfileWithBreakWater(BreakWaterType type, double height)
        {
            // Setup
            var foreshorePoints = new Point2D[0];
            var roughnessPoints = new[]
            {
                new RoughnessPoint(new Point2D(1.1, 2.2), 1.0),
                new RoughnessPoint(new Point2D(3.3, 4.4), 0.6),
                new RoughnessPoint(new Point2D(5.5, 6.6), 1.0),
                new RoughnessPoint(new Point2D(7.7, 8.8), 0.5)
            };
            var entity = new DikeProfileEntity
            {
                Id               = "with_breakwater",
                Name             = "I have a Breakwater!",
                Orientation      = 360.0,
                BreakWaterHeight = height,
                BreakWaterType   = Convert.ToByte(type),
                ForeshoreXml     = new Point2DCollectionXmlSerializer().ToXml(foreshorePoints),
                DikeGeometryXml  = new RoughnessPointCollectionXmlSerializer().ToXml(roughnessPoints),
                DikeHeight       = 4.5,
                X  = 93.0,
                Y  = 945.6,
                X0 = 9.34
            };

            var collector = new ReadConversionCollector();

            // Call
            DikeProfile dikeProfile = entity.Read(collector);

            // Assert
            Assert.AreEqual(entity.Id, dikeProfile.Id);
            Assert.AreEqual(entity.Name, dikeProfile.Name);
            Assert.AreEqual(entity.Orientation, dikeProfile.Orientation.Value);
            CollectionAssert.AreEqual(foreshorePoints, dikeProfile.ForeshoreGeometry);
            CollectionAssert.AreEqual(roughnessPoints, dikeProfile.DikeGeometry, new RoughnessPointComparer());
            Assert.AreEqual(entity.X, dikeProfile.WorldReferencePoint.X);
            Assert.AreEqual(entity.Y, dikeProfile.WorldReferencePoint.Y);
            Assert.AreEqual(entity.X0, dikeProfile.X0);

            Assert.AreEqual(height, dikeProfile.BreakWater.Height.Value);
            Assert.AreEqual(type, dikeProfile.BreakWater.Type);

            Assert.IsTrue(collector.Contains(entity));
        }