Exemplo n.º 1
0
        public void Create_HasHydraulicLocationCalculationsForTargetProbability_EntityHasHydraulicLocationCalculationForTargetProbabilityCollectionEntity()
        {
            // Setup
            var random = new Random(21);
            var hydraulicCalculations       = new HydraulicBoundaryLocationCalculationsForTargetProbability(random.NextDouble(0, 0.1));
            var hydraulicCalculationsEntity = new HydraulicLocationCalculationForTargetProbabilityCollectionEntity();

            var registry = new PersistenceRegistry();

            registry.Register(hydraulicCalculationsEntity, hydraulicCalculations);

            var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation
            {
                InputParameters =
                {
                    CalculationsTargetProbability = hydraulicCalculations
                }
            };

            // Call
            GrassCoverErosionOutwardsWaveConditionsCalculationEntity entity = calculation.Create(registry, 0);

            // Assert
            Assert.AreSame(hydraulicCalculationsEntity, entity.HydraulicLocationCalculationForTargetProbabilityCollectionEntity);
        }
Exemplo n.º 2
0
        public void Create_HasCalculationOutputWithWaveImpactWithWaveDirection_EntityHasCalculationOutputEntity()
        {
            // Setup
            var registry    = new PersistenceRegistry();
            var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation
            {
                Output = GrassCoverErosionOutwardsWaveConditionsOutputFactory.CreateOutputWithWaveImpactWithWaveDirection(
                    new[]
                {
                    new TestWaveConditionsOutput(),
                    new TestWaveConditionsOutput()
                })
            };

            // Call
            GrassCoverErosionOutwardsWaveConditionsCalculationEntity entity = calculation.Create(registry, 0);

            // Assert
            ICollection <GrassCoverErosionOutwardsWaveConditionsOutputEntity> outputEntities = entity.GrassCoverErosionOutwardsWaveConditionsOutputEntities;

            Assert.AreEqual(2, outputEntities.Count);
            CollectionAssert.AreEqual(new[]
            {
                0,
                1
            }, outputEntities.Select(oe => oe.Order));

            Assert.IsTrue(outputEntities.All(oe => oe.OutputType == Convert.ToByte(GrassCoverErosionOutwardsWaveConditionsOutputType.WaveImpactWithWaveDirection)));
        }
Exemplo n.º 3
0
        public void Create_CalculationWithNaNProperties_ReturnCalculationEntity()
        {
            // Setup
            var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation
            {
                InputParameters =
                {
                    Orientation              = RoundedDouble.NaN,
                    UpperBoundaryRevetment   = RoundedDouble.NaN,
                    LowerBoundaryRevetment   = RoundedDouble.NaN,
                    UpperBoundaryWaterLevels = RoundedDouble.NaN,
                    LowerBoundaryWaterLevels = RoundedDouble.NaN,
                    BreakWater               =
                    {
                        Height               = RoundedDouble.NaN
                    }
                }
            };

            var registry = new PersistenceRegistry();

            // Call
            GrassCoverErosionOutwardsWaveConditionsCalculationEntity entity = calculation.Create(registry, 1234);

            // Assert
            Assert.IsNull(entity.Orientation);
            Assert.IsNull(entity.UpperBoundaryRevetment);
            Assert.IsNull(entity.LowerBoundaryRevetment);
            Assert.IsNull(entity.UpperBoundaryWaterLevels);
            Assert.IsNull(entity.LowerBoundaryWaterLevels);
            Assert.IsNull(entity.BreakWaterHeight);
        }
Exemplo n.º 4
0
        public void Create_PersistenceRegistryNull_ThrowArgumentNullException()
        {
            // Setup
            var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation();

            // Call
            TestDelegate call = () => calculation.Create(null, 0);

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

            Assert.AreEqual(paramName, "registry");
        }
Exemplo n.º 5
0
        public void Create_CalculationWithPropertiesSet_ReturnCalculationEntity()
        {
            // Setup
            var random = new Random(21);
            int order  = random.Next();

            var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation
            {
                InputParameters =
                {
                    Orientation              = random.NextRoundedDouble(0,                                                      360),
                    UseBreakWater            = random.NextBoolean(),
                    UseForeshore             = random.NextBoolean(),
                    UpperBoundaryRevetment   = (RoundedDouble)6.10,
                    LowerBoundaryRevetment   = (RoundedDouble)3.58,
                    UpperBoundaryWaterLevels = (RoundedDouble)5.88,
                    LowerBoundaryWaterLevels = (RoundedDouble)3.40,
                    StepSize        = random.NextEnumValue <WaveConditionsInputStepSize>(),
                    CalculationType = random.NextEnumValue <GrassCoverErosionOutwardsWaveConditionsCalculationType>(),
                    WaterLevelType  = random.NextEnumValue <WaveConditionsInputWaterLevelType>()
                }
            };

            var registry = new PersistenceRegistry();

            // Call
            GrassCoverErosionOutwardsWaveConditionsCalculationEntity entity = calculation.Create(registry, order);

            // Assert
            GrassCoverErosionOutwardsWaveConditionsInput input = calculation.InputParameters;

            Assert.AreEqual(input.Orientation, entity.Orientation, input.Orientation.GetAccuracy());
            Assert.AreEqual(Convert.ToByte(input.UseBreakWater), entity.UseBreakWater);
            Assert.AreEqual(Convert.ToByte(input.UseForeshore), entity.UseForeshore);
            Assert.AreEqual(input.UpperBoundaryRevetment, entity.UpperBoundaryRevetment, input.UpperBoundaryRevetment.GetAccuracy());
            Assert.AreEqual(input.LowerBoundaryRevetment, entity.LowerBoundaryRevetment, input.LowerBoundaryRevetment.GetAccuracy());
            Assert.AreEqual(input.UpperBoundaryWaterLevels, entity.UpperBoundaryWaterLevels, input.UpperBoundaryWaterLevels.GetAccuracy());
            Assert.AreEqual(input.LowerBoundaryWaterLevels, entity.LowerBoundaryWaterLevels, input.LowerBoundaryWaterLevels.GetAccuracy());
            Assert.AreEqual(Convert.ToByte(input.StepSize), entity.StepSize);
            Assert.AreEqual(Convert.ToByte(input.CalculationType), entity.CalculationType);
            Assert.AreEqual(Convert.ToByte(input.WaterLevelType), entity.WaterLevelType);

            Assert.AreEqual(order, entity.Order);
            Assert.IsNull(entity.CalculationGroupEntity);
            CollectionAssert.IsEmpty(entity.GrassCoverErosionOutwardsWaveConditionsOutputEntities);
            Assert.IsNull(entity.ForeshoreProfileEntity);
            Assert.IsNull(entity.HydraulicLocationEntity);
            Assert.IsNull(entity.HydraulicLocationCalculationForTargetProbabilityCollectionEntity);
        }
Exemplo n.º 6
0
        public void Create_HasForeshoreProfile_EntityHasForeshoreProfileEntity()
        {
            // Setup
            var registry    = new PersistenceRegistry();
            var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation
            {
                InputParameters =
                {
                    ForeshoreProfile = new TestForeshoreProfile()
                }
            };

            // Call
            GrassCoverErosionOutwardsWaveConditionsCalculationEntity entity = calculation.Create(registry, 0);

            // Assert
            Assert.IsNotNull(entity.ForeshoreProfileEntity);
        }
Exemplo n.º 7
0
        public void Create_HasCalculationOutputWithWaveRunUpAndWaveImpact_EntityHasCalculationOutputEntity()
        {
            // Setup
            var registry    = new PersistenceRegistry();
            var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation
            {
                Output = GrassCoverErosionOutwardsWaveConditionsOutputFactory.CreateOutputWithWaveRunUpWaveImpactAndWaveImpactWithWaveDirection(
                    new[]
                {
                    new TestWaveConditionsOutput()
                },
                    new[]
                {
                    new TestWaveConditionsOutput()
                },
                    new[]
                {
                    new TestWaveConditionsOutput()
                })
            };

            // Call
            GrassCoverErosionOutwardsWaveConditionsCalculationEntity entity = calculation.Create(registry, 0);

            // Assert
            ICollection <GrassCoverErosionOutwardsWaveConditionsOutputEntity> outputEntities = entity.GrassCoverErosionOutwardsWaveConditionsOutputEntities;

            Assert.AreEqual(3, outputEntities.Count);
            CollectionAssert.AreEqual(new[]
            {
                0,
                1,
                2
            }, outputEntities.Select(oe => oe.Order));

            Assert.AreEqual(Convert.ToByte(GrassCoverErosionOutwardsWaveConditionsOutputType.WaveRunUp), outputEntities.ElementAt(0).OutputType);
            Assert.AreEqual(Convert.ToByte(GrassCoverErosionOutwardsWaveConditionsOutputType.WaveImpact), outputEntities.ElementAt(1).OutputType);
            Assert.AreEqual(Convert.ToByte(GrassCoverErosionOutwardsWaveConditionsOutputType.WaveImpactWithWaveDirection), outputEntities.ElementAt(2).OutputType);
        }
Exemplo n.º 8
0
        public void Create_StringPropertiesDoNotShareReference()
        {
            // Setup
            const string name        = "A";
            const string comments    = "B";
            var          calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation
            {
                Name     = name,
                Comments =
                {
                    Body = comments
                }
            };

            var registry = new PersistenceRegistry();

            // Call
            GrassCoverErosionOutwardsWaveConditionsCalculationEntity entity = calculation.Create(registry, 0);

            // Assert
            TestHelper.AssertAreEqualButNotSame(calculation.Name, entity.Name);
            TestHelper.AssertAreEqualButNotSame(calculation.Comments.Body, entity.Comments);
        }
Exemplo n.º 9
0
        public void Create_HasHydraulicLocationEntity_EntityHasHydraulicLocationEntity()
        {
            // Setup
            var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "A", 2.3, 4.5);

            var calculation = new GrassCoverErosionOutwardsWaveConditionsCalculation
            {
                InputParameters =
                {
                    HydraulicBoundaryLocation = hydraulicBoundaryLocation
                }
            };

            HydraulicLocationEntity hydraulicLocationEntity = HydraulicLocationEntityTestFactory.CreateHydraulicLocationEntity();
            var registry = new PersistenceRegistry();

            registry.Register(hydraulicLocationEntity, hydraulicBoundaryLocation);

            // Call
            GrassCoverErosionOutwardsWaveConditionsCalculationEntity entity = calculation.Create(registry, 0);

            // Assert
            Assert.AreSame(hydraulicLocationEntity, entity.HydraulicLocationEntity);
        }