コード例 #1
0
        public void WidthFlowApertures_Always_ExpectedValues()
        {
            // Setup
            var random            = new Random(22);
            var input             = new SimpleStructuresInput();
            var mean              = (RoundedDouble)(0.01 + random.NextDouble());
            var standardDeviation = (RoundedDouble)(0.01 + random.NextDouble());
            var distributionToSet = new NormalDistribution(5)
            {
                Mean = mean,
                StandardDeviation = standardDeviation
            };

            // Call
            input.WidthFlowApertures = distributionToSet;

            // Assert
            var expectedDistribution = new NormalDistribution(2)
            {
                Mean = mean,
                StandardDeviation = standardDeviation
            };

            DistributionTestHelper.AssertDistributionCorrectlySet(input.WidthFlowApertures, distributionToSet, expectedDistribution);
        }
コード例 #2
0
        private static void AssertForeshoreProfilePropertiesOfInput(ForeshoreProfile expectedForeshoreProfile, SimpleStructuresInput input)
        {
            var defaultInput = new SimpleStructuresInput();

            if (expectedForeshoreProfile == null)
            {
                Assert.AreEqual(defaultInput.UseBreakWater, input.UseBreakWater);
                Assert.AreEqual(defaultInput.UseForeshore, input.UseForeshore);
            }
            else
            {
                Assert.AreEqual(expectedForeshoreProfile.Geometry.Count() > 1, input.UseForeshore);
                Assert.AreEqual(expectedForeshoreProfile.HasBreakWater, input.UseBreakWater);
            }

            if (expectedForeshoreProfile?.BreakWater == null)
            {
                Assert.AreEqual(defaultInput.BreakWater.Type, input.BreakWater.Type);
                Assert.AreEqual(defaultInput.BreakWater.Height, input.BreakWater.Height);
            }
            else
            {
                Assert.AreEqual(expectedForeshoreProfile.BreakWater.Type, input.BreakWater.Type);
                Assert.AreEqual(expectedForeshoreProfile.BreakWater.Height, input.BreakWater.Height);
            }
        }
コード例 #3
0
        public void SetConfigurationForeshoreProfileDependentProperties_WithForeshoreProfileInvalidBreakwaterType_UpdatesConfiguration()
        {
            // Setup
            var random         = new Random(6543);
            var configuration  = new SimpleStructuresCalculationConfiguration();
            var structureInput = new SimpleStructuresInput
            {
                ForeshoreProfile = new TestForeshoreProfile(new BreakWater(
                                                                (BreakWaterType)999,
                                                                random.NextDouble())),
                UseBreakWater = random.NextBoolean(),
                UseForeshore  = random.NextBoolean()
            };

            // Call
            configuration.SetConfigurationForeshoreProfileDependentProperties(structureInput);

            // Assert
            Assert.AreEqual(structureInput.ForeshoreProfile.Id, configuration.ForeshoreProfileId);
            WaveReductionConfiguration waveReduction = configuration.WaveReduction;

            Assert.AreEqual(structureInput.UseBreakWater, waveReduction.UseBreakWater);
            Assert.AreEqual(structureInput.UseForeshore, waveReduction.UseForeshoreProfile);
            Assert.IsNull(waveReduction.BreakWaterType);
            Assert.AreEqual(structureInput.BreakWater.Height, waveReduction.BreakWaterHeight);
        }
コード例 #4
0
        public void CriticalOvertoppingDischarge_Always_ExpectedValues()
        {
            // Setup
            var random            = new Random(22);
            var input             = new SimpleStructuresInput();
            var mean              = (RoundedDouble)(0.01 + random.NextDouble());
            var variation         = (RoundedDouble)(0.01 + random.NextDouble());
            var distributionToSet = new VariationCoefficientLogNormalDistribution(5)
            {
                Mean = mean,
                CoefficientOfVariation = variation
            };

            // Call
            input.CriticalOvertoppingDischarge = distributionToSet;

            // Assert
            var expectedDistribution = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = mean,
                CoefficientOfVariation = variation
            };

            DistributionTestHelper.AssertDistributionCorrectlySet(input.CriticalOvertoppingDischarge, distributionToSet, expectedDistribution);
        }
コード例 #5
0
        public void SetConfigurationForeshoreProfileDependentProperties_WithForeshoreProfile_UpdatesConfiguration()
        {
            // Setup
            var random         = new Random(6543);
            var configuration  = new SimpleStructuresCalculationConfiguration();
            var structureInput = new SimpleStructuresInput
            {
                ForeshoreProfile = new ForeshoreProfile(new Point2D(0, 0),
                                                        Enumerable.Empty <Point2D>(),
                                                        new BreakWater(
                                                            BreakWaterType.Dam,
                                                            random.NextDouble()),
                                                        new ForeshoreProfile.ConstructionProperties
                {
                    Id   = "id",
                    Name = "profile"
                }),
                UseBreakWater = random.NextBoolean(),
                UseForeshore  = random.NextBoolean()
            };

            // Call
            configuration.SetConfigurationForeshoreProfileDependentProperties(structureInput);

            // Assert
            Assert.AreEqual("id", configuration.ForeshoreProfileId);
            WaveReductionConfiguration waveReduction = configuration.WaveReduction;

            Assert.AreEqual(structureInput.UseBreakWater, waveReduction.UseBreakWater);
            Assert.AreEqual(structureInput.UseForeshore, waveReduction.UseForeshoreProfile);
            Assert.AreEqual(ConfigurationBreakWaterType.Dam, waveReduction.BreakWaterType);
            Assert.AreEqual(structureInput.BreakWater.Height, waveReduction.BreakWaterHeight);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
        public void FailureProbabilityStructureWithErosion_ValidValues_ExpectedValues(double failureProbabilityStructureWithErosion)
        {
            // Setup
            var input = new SimpleStructuresInput();

            // Call
            input.FailureProbabilityStructureWithErosion = failureProbabilityStructureWithErosion;

            // Assert
            Assert.AreEqual(failureProbabilityStructureWithErosion, input.FailureProbabilityStructureWithErosion);
        }
コード例 #8
0
        public void StructureNormalOrientation_InvalidValues_ThrowsArgumentOutOfRangeException(double invalidValue)
        {
            // Setup
            var input = new SimpleStructuresInput();

            // Call
            TestDelegate call = () => input.StructureNormalOrientation = (RoundedDouble)invalidValue;

            // Assert
            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(call, "De waarde voor de oriëntatie moet in het bereik [0,00, 360,00] liggen.");
        }
コード例 #9
0
        public void IsForeshoreProfileInputSynchronized_ForeshoreProfileNotSet_ReturnFalse()
        {
            // Setup
            var input = new SimpleStructuresInput();

            // Call
            bool isSynchronized = input.IsForeshoreProfileInputSynchronized;

            // Assert
            Assert.IsFalse(isSynchronized);
        }
コード例 #10
0
        public void FailureProbabilityStructureWithErosion_InvalidValues_ThrowArgumentOutOfRangeException(double failureProbabilityStructureWithErosion)
        {
            // Setup
            var input = new SimpleStructuresInput();

            // Call
            TestDelegate call = () => input.FailureProbabilityStructureWithErosion = (RoundedDouble)failureProbabilityStructureWithErosion;

            // Assert
            TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(call, "De waarde voor de faalkans moet in het bereik [0,0, 1,0] liggen.");
        }
コード例 #11
0
        public void Read_ValidEntity_InputObjectUpdated()
        {
            // Setup
            var random = new Random(78);

            var mocks  = new MockRepository();
            var entity = mocks.Stub <IStructuresCalculationEntity>();

            entity.StructureNormalOrientation      = random.NextDouble(0, 360);
            entity.AllowedLevelIncreaseStorageMean = random.NextDouble(1e-6, 9999.9999);
            entity.AllowedLevelIncreaseStorageStandardDeviation = random.NextDouble(1e-6, 9999.9999);
            entity.FlowWidthAtBottomProtectionMean = random.NextDouble(1e-6, 9999.9999);
            entity.FlowWidthAtBottomProtectionStandardDeviation       = random.NextDouble(1e-6, 9999.9999);
            entity.CriticalOvertoppingDischargeMean                   = random.NextDouble(1e-6, 9999.9999);
            entity.CriticalOvertoppingDischargeCoefficientOfVariation = random.NextDouble(1e-6, 9999.9999);
            entity.FailureProbabilityStructureWithErosion             = random.NextDouble();
            entity.WidthFlowAperturesMean = random.NextDouble(1e-6, 9999.9999);
            entity.WidthFlowAperturesStandardDeviation = random.NextDouble(1e-6, 9999.9999);
            entity.StormDurationMean = random.NextDouble(1e-6, 9999.9999);
            entity.UseForeshore      = Convert.ToByte(random.NextBoolean());
            entity.UseBreakWater     = Convert.ToByte(random.NextBoolean());
            entity.ShouldIllustrationPointsBeCalculated = Convert.ToByte(random.NextBoolean());
            mocks.ReplayAll();

            var inputToUpdate = new SimpleStructuresInput();
            var collector     = new ReadConversionCollector();

            // Call
            entity.Read(inputToUpdate, collector);

            // Assert
            AssertBoolean(entity.UseForeshore, inputToUpdate.UseForeshore);
            AssertBoolean(entity.UseBreakWater, inputToUpdate.UseBreakWater);
            AssertBoolean(entity.ShouldIllustrationPointsBeCalculated, inputToUpdate.ShouldIllustrationPointsBeCalculated);

            RoundedDoubleTestHelper.AssertRoundedDouble(entity.StructureNormalOrientation, inputToUpdate.StructureNormalOrientation);
            RoundedDoubleTestHelper.AssertRoundedDouble(entity.AllowedLevelIncreaseStorageMean, inputToUpdate.AllowedLevelIncreaseStorage.Mean);
            RoundedDoubleTestHelper.AssertRoundedDouble(entity.AllowedLevelIncreaseStorageStandardDeviation, inputToUpdate.AllowedLevelIncreaseStorage.StandardDeviation);
            RoundedDoubleTestHelper.AssertRoundedDouble(entity.FlowWidthAtBottomProtectionMean, inputToUpdate.FlowWidthAtBottomProtection.Mean);
            RoundedDoubleTestHelper.AssertRoundedDouble(entity.FlowWidthAtBottomProtectionStandardDeviation, inputToUpdate.FlowWidthAtBottomProtection.StandardDeviation);
            RoundedDoubleTestHelper.AssertRoundedDouble(entity.CriticalOvertoppingDischargeMean, inputToUpdate.CriticalOvertoppingDischarge.Mean);
            RoundedDoubleTestHelper.AssertRoundedDouble(entity.CriticalOvertoppingDischargeCoefficientOfVariation, inputToUpdate.CriticalOvertoppingDischarge.CoefficientOfVariation);
            Assert.AreEqual(entity.FailureProbabilityStructureWithErosion, inputToUpdate.FailureProbabilityStructureWithErosion);
            RoundedDoubleTestHelper.AssertRoundedDouble(entity.WidthFlowAperturesMean, inputToUpdate.WidthFlowApertures.Mean);
            RoundedDoubleTestHelper.AssertRoundedDouble(entity.WidthFlowAperturesStandardDeviation, inputToUpdate.WidthFlowApertures.StandardDeviation);
            RoundedDoubleTestHelper.AssertRoundedDouble(entity.StormDurationMean, inputToUpdate.StormDuration.Mean);

            CollectionAssert.IsEmpty(inputToUpdate.ForeshoreGeometry);
            Assert.IsNull(inputToUpdate.ForeshoreProfile);
            Assert.IsNull(inputToUpdate.HydraulicBoundaryLocation);
            Assert.IsNull(inputToUpdate.Structure);
            mocks.VerifyAll();
        }
コード例 #12
0
        public void StructureNormalOrientation_ValidValues_ExpectedValues(double orientation)
        {
            // Setup
            var input = new SimpleStructuresInput();

            // Call
            input.StructureNormalOrientation = (RoundedDouble)orientation;

            // Assert
            Assert.AreEqual(2, input.StructureNormalOrientation.NumberOfDecimalPlaces);
            AssertAreEqual(orientation, input.StructureNormalOrientation);
        }
コード例 #13
0
        public void SetConfigurationForeshoreProfileDependentProperties_ConfigurationNull_ThrowsArgumentNullException()
        {
            // Setup
            var structureInput = new SimpleStructuresInput();

            // Call
            TestDelegate call = () => WaveReductionConversionExtensions.SetConfigurationForeshoreProfileDependentProperties(null, structureInput);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(call).ParamName;

            Assert.AreEqual("configuration", paramName);
        }
コード例 #14
0
        public void SetConfigurationForeshoreProfileDependentProperties_WithoutForeshoreProfile_DoesNotUpdate()
        {
            // Setup
            var configuration  = new SimpleStructuresCalculationConfiguration();
            var structureInput = new SimpleStructuresInput();

            // Call
            configuration.SetConfigurationForeshoreProfileDependentProperties(structureInput);

            // Assert
            Assert.IsNull(configuration.ForeshoreProfileId);
            Assert.IsNull(configuration.WaveReduction);
        }
コード例 #15
0
        public void ClearStructure_ClearsStructure()
        {
            // Setup
            var input = new SimpleStructuresInput
            {
                Structure = new TestStructure()
            };

            // Call
            input.ClearStructure();

            // Assert
            Assert.IsNull(input.Structure);
        }
コード例 #16
0
        public void IsForeshoreProfileInputSynchronized_ForeshoreProfileAndInputInSync_ReturnTrue()
        {
            // Setup
            var input = new SimpleStructuresInput
            {
                ForeshoreProfile = new TestForeshoreProfile()
            };

            // Call
            bool isSynchronized = input.IsForeshoreProfileInputSynchronized;

            // Assert
            Assert.IsTrue(isSynchronized);
        }
コード例 #17
0
        public void IsForeshoreProfileInputSynchronized_ForeshoreProfilesOutOfSync_ReturnFalse(ForeshoreProfile modifiedProfile)
        {
            // Setup
            var input = new SimpleStructuresInput
            {
                ForeshoreProfile = new TestForeshoreProfile()
            };

            input.ForeshoreProfile.CopyProperties(modifiedProfile);

            // Call
            bool isSynchronized = input.IsForeshoreProfileInputSynchronized;

            // Assert
            Assert.IsFalse(isSynchronized);
        }
コード例 #18
0
        public void Structure_Always_ExpectedValues()
        {
            // Setup
            var structure = new TestStructure();
            var input     = new SimpleStructuresInput();

            // Precondition
            Assert.IsFalse(input.Synchronized);

            // Call
            input.Structure = structure;

            // Assert
            Assert.AreSame(structure, input.Structure);
            Assert.IsTrue(input.Synchronized);
        }
コード例 #19
0
        public void Clone_Always_ReturnNewInstanceWithCopiedValues()
        {
            // Setup
            var original = new SimpleStructuresInput
            {
                Structure = new TestStructure()
            };

            CommonTestDataGenerator.SetRandomDataToStructuresInput(original);

            // Call
            object clone = original.Clone();

            // Assert
            CoreCloneAssert.AreObjectClones(original, clone, CommonCloneAssert.AreClones);
        }
コード例 #20
0
        public void Read_ReadConversionCollectorIsNull_ThrowArgumentNullException()
        {
            // Setup
            var mocks  = new MockRepository();
            var entity = mocks.Stub <IStructuresCalculationEntity>();

            mocks.ReplayAll();

            var inputToUpdate = new SimpleStructuresInput();

            // Call
            TestDelegate call = () => entity.Read(inputToUpdate, null);

            // Assert
            string paramName = Assert.Throws <ArgumentNullException>(call).ParamName;

            Assert.AreEqual("collector", paramName);
            mocks.VerifyAll();
        }
コード例 #21
0
        public void ForeshoreProfile_SetNullValue_InputSyncedToDefaults()
        {
            // Setup
            var                       input = new SimpleStructuresInput();
            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.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.AreSame(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation);

            // Call
            input.ForeshoreProfile = null;

            // Assert
            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.AreSame(originalHydraulicBoundaryLocation, input.HydraulicBoundaryLocation);
        }
コード例 #22
0
        public void SynchronizeForeshoreProfileInput_ForeshoreProfileNotSet_ExpectedValues()
        {
            // Setup
            var input = new SimpleStructuresInput
            {
                UseBreakWater = true,
                UseForeshore  = true,
                BreakWater    =
                {
                    Height = (RoundedDouble)1.0,
                    Type   = BreakWaterType.Caisson
                }
            };

            // Call
            input.SynchronizeForeshoreProfileInput();

            // Assert
            AssertForeshoreProfilePropertiesOfInput(null, input);
        }
コード例 #23
0
        public void SynchronizeForeshoreProfileInput_ChangedForeshoreProfile_ExpectedValues()
        {
            // Setup
            var differentProfile = new TestForeshoreProfile(true);
            var input            = new SimpleStructuresInput
            {
                ForeshoreProfile = new TestForeshoreProfile()
            };

            input.ForeshoreProfile.CopyProperties(differentProfile);

            // Precondition
            AssertForeshoreProfilePropertiesOfInput(new TestForeshoreProfile(), input);

            // Call
            input.SynchronizeForeshoreProfileInput();

            // Assert
            AssertForeshoreProfilePropertiesOfInput(differentProfile, input);
        }
コード例 #24
0
        public void StormDuration_Always_ExpectedValues()
        {
            // Setup
            var           random = new Random(22);
            var           input  = new SimpleStructuresInput();
            RoundedDouble mean   = random.NextRoundedDouble(0.01, 1.0);
            var           expectedDistribution = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = mean,
                CoefficientOfVariation = input.StormDuration.CoefficientOfVariation
            };
            var distributionToSet = new VariationCoefficientLogNormalDistribution(5)
            {
                Mean = mean,
                CoefficientOfVariation = random.NextRoundedDouble()
            };

            // Call
            input.StormDuration = distributionToSet;

            // Assert
            DistributionTestHelper.AssertDistributionCorrectlySet(input.StormDuration, distributionToSet, expectedDistribution);
        }
コード例 #25
0
        public void Read_EntityWithParametersNull_InputObjectUpdatedWithNaN()
        {
            // Setup
            var mocks  = new MockRepository();
            var entity = mocks.Stub <IStructuresCalculationEntity>();

            entity.StructureNormalOrientation      = null;
            entity.AllowedLevelIncreaseStorageMean = null;
            entity.AllowedLevelIncreaseStorageStandardDeviation = null;
            entity.FlowWidthAtBottomProtectionMean = null;
            entity.FlowWidthAtBottomProtectionStandardDeviation       = null;
            entity.CriticalOvertoppingDischargeMean                   = null;
            entity.CriticalOvertoppingDischargeCoefficientOfVariation = null;
            entity.WidthFlowAperturesMean = null;
            entity.WidthFlowAperturesStandardDeviation = null;
            entity.StormDurationMean = null;
            mocks.ReplayAll();

            var inputToUpdate = new SimpleStructuresInput();
            var collector     = new ReadConversionCollector();

            // Call
            entity.Read(inputToUpdate, collector);

            // Assert
            Assert.IsNaN(inputToUpdate.StructureNormalOrientation);
            Assert.IsNaN(inputToUpdate.AllowedLevelIncreaseStorage.Mean);
            Assert.IsNaN(inputToUpdate.AllowedLevelIncreaseStorage.StandardDeviation);
            Assert.IsNaN(inputToUpdate.FlowWidthAtBottomProtection.Mean);
            Assert.IsNaN(inputToUpdate.FlowWidthAtBottomProtection.StandardDeviation);
            Assert.IsNaN(inputToUpdate.CriticalOvertoppingDischarge.Mean);
            Assert.IsNaN(inputToUpdate.CriticalOvertoppingDischarge.CoefficientOfVariation);
            Assert.IsNaN(inputToUpdate.WidthFlowApertures.Mean);
            Assert.IsNaN(inputToUpdate.WidthFlowApertures.StandardDeviation);
            Assert.IsNaN(inputToUpdate.StormDuration.Mean);
            mocks.VerifyAll();
        }
コード例 #26
0
        public void Read_EntityWithForeshoreProfileEntity_InputObjectUpdatedWithForeshoreProfile()
        {
            // Setup
            var foreshoreProfile = new TestForeshoreProfile();
            var foreshoreEntity  = new ForeshoreProfileEntity();

            var mocks  = new MockRepository();
            var entity = mocks.Stub <IStructuresCalculationEntity>();

            entity.ForeshoreProfileEntity = foreshoreEntity;
            mocks.ReplayAll();

            var inputToUpdate = new SimpleStructuresInput();
            var collector     = new ReadConversionCollector();

            collector.Read(foreshoreEntity, foreshoreProfile);

            // Call
            entity.Read(inputToUpdate, collector);

            // Assert
            Assert.AreSame(foreshoreProfile, inputToUpdate.ForeshoreProfile);
            mocks.VerifyAll();
        }
コード例 #27
0
        public void Read_EntityWithHydraulicLocationEntity_InputObjectUpdatedWithHydraulicBoundaryLocation()
        {
            // Setup
            var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, "A", 0, 0);
            var hydraulicLocationEntity   = new HydraulicLocationEntity();

            var mocks  = new MockRepository();
            var entity = mocks.Stub <IStructuresCalculationEntity>();

            entity.HydraulicLocationEntity = hydraulicLocationEntity;
            mocks.ReplayAll();

            var inputToUpdate = new SimpleStructuresInput();
            var collector     = new ReadConversionCollector();

            collector.Read(hydraulicLocationEntity, hydraulicBoundaryLocation);

            // Call
            entity.Read(inputToUpdate, collector);

            // Assert
            Assert.AreSame(hydraulicBoundaryLocation, inputToUpdate.HydraulicBoundaryLocation);
            mocks.VerifyAll();
        }
コード例 #28
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);
        }
コード例 #29
0
        public void Constructor_ExpectedValues()
        {
            // Call
            var input = new SimpleStructuresInput();

            // Assert
            Assert.IsInstanceOf <CloneableObservable>(input);
            Assert.IsInstanceOf <IStructuresCalculationInput <StructureBase> >(input);
            Assert.IsInstanceOf <IUseBreakWater>(input);
            Assert.IsInstanceOf <IUseForeshore>(input);
            Assert.IsInstanceOf <IHasForeshoreProfile>(input);

            Assert.IsNull(input.Structure);
            Assert.IsNull(input.HydraulicBoundaryLocation);

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

            Assert.IsNull(input.ForeshoreProfile);
            Assert.IsFalse(input.UseBreakWater);
            Assert.AreEqual(BreakWaterType.Dam, input.BreakWater.Type);
            Assert.AreEqual(0, input.BreakWater.Height.Value);
            Assert.AreEqual(2, input.BreakWater.Height.NumberOfDecimalPlaces);
            Assert.IsFalse(input.UseForeshore);
            CollectionAssert.IsEmpty(input.ForeshoreGeometry);

            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
            };

            var expectedStormDuration = new VariationCoefficientLogNormalDistribution(2)
            {
                Mean = (RoundedDouble)6.0,
                CoefficientOfVariation = (RoundedDouble)0.25
            };

            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);
            DistributionAssert.AreEqual(expectedStormDuration, input.StormDuration);

            Assert.AreEqual(1.0, input.FailureProbabilityStructureWithErosion);

            Assert.IsFalse(input.ShouldIllustrationPointsBeCalculated);
        }