Exemplo n.º 1
0
        private static void SetInputParameters(WaveImpactAsphaltCoverWaveConditionsCalculationEntity entity,
                                               WaveConditionsInput calculationInput,
                                               PersistenceRegistry registry)
        {
            HydraulicBoundaryLocation hydraulicBoundaryLocation = calculationInput.HydraulicBoundaryLocation;

            if (hydraulicBoundaryLocation != null)
            {
                entity.HydraulicLocationEntity = hydraulicBoundaryLocation.Create(registry, 0);
            }

            if (calculationInput.ForeshoreProfile != null)
            {
                entity.ForeshoreProfileEntity = calculationInput.ForeshoreProfile.Create(registry, 0);
            }

            if (calculationInput.CalculationsTargetProbability != null)
            {
                entity.HydraulicLocationCalculationForTargetProbabilityCollectionEntity =
                    calculationInput.CalculationsTargetProbability.Create(HydraulicBoundaryLocationCalculationType.WaterLevel, 0, registry);
            }

            entity.Orientation              = calculationInput.Orientation.ToNaNAsNull();
            entity.UseBreakWater            = Convert.ToByte(calculationInput.UseBreakWater);
            entity.BreakWaterType           = Convert.ToByte(calculationInput.BreakWater.Type);
            entity.BreakWaterHeight         = calculationInput.BreakWater.Height.ToNaNAsNull();
            entity.UseForeshore             = Convert.ToByte(calculationInput.UseForeshore);
            entity.UpperBoundaryRevetment   = calculationInput.UpperBoundaryRevetment.ToNaNAsNull();
            entity.LowerBoundaryRevetment   = calculationInput.LowerBoundaryRevetment.ToNaNAsNull();
            entity.UpperBoundaryWaterLevels = calculationInput.UpperBoundaryWaterLevels.ToNaNAsNull();
            entity.LowerBoundaryWaterLevels = calculationInput.LowerBoundaryWaterLevels.ToNaNAsNull();
            entity.StepSize       = Convert.ToByte(calculationInput.StepSize);
            entity.WaterLevelType = Convert.ToByte(calculationInput.WaterLevelType);
        }
        public void Read_EntityWithNullValues_ReturnCalculationWithNaNValues()
        {
            // Setup
            var entity    = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity();
            var collector = new ReadConversionCollector();

            // Call
            WaveImpactAsphaltCoverWaveConditionsCalculation calculation = entity.Read(collector);

            // Assert
            Assert.IsNull(calculation.Name);
            Assert.IsNull(calculation.Comments.Body);

            WaveConditionsInput calculationInput = calculation.InputParameters;

            Assert.IsNaN(calculationInput.BreakWater.Height);
            Assert.IsNaN(calculationInput.Orientation);
            Assert.IsNaN(calculationInput.UpperBoundaryRevetment);
            Assert.IsNaN(calculationInput.LowerBoundaryRevetment);
            Assert.IsNaN(calculationInput.UpperBoundaryWaterLevels);
            Assert.IsNaN(calculationInput.LowerBoundaryWaterLevels);

            Assert.IsNull(calculationInput.HydraulicBoundaryLocation);
            Assert.IsNull(calculationInput.ForeshoreProfile);
            Assert.IsNull(calculation.Output);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Reads the <see cref="WaveImpactAsphaltCoverWaveConditionsCalculationEntity"/> and use the
        /// information to update a <see cref="WaveImpactAsphaltCoverWaveConditionsCalculation"/>.
        /// </summary>
        /// <param name="entity">
        /// The <see cref="WaveImpactAsphaltCoverWaveConditionsCalculationEntity"/>
        /// to create <see cref="WaveImpactAsphaltCoverWaveConditionsCalculation"/> for.
        /// </param>
        /// <param name="collector">The object keeping track of read operations.</param>
        /// <returns>A new <see cref="WaveImpactAsphaltCoverWaveConditionsCalculation"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        internal static WaveImpactAsphaltCoverWaveConditionsCalculation Read(this WaveImpactAsphaltCoverWaveConditionsCalculationEntity entity,
                                                                             ReadConversionCollector collector)
        {
            if (entity == null)
            {
                throw new ArgumentNullException(nameof(entity));
            }

            if (collector == null)
            {
                throw new ArgumentNullException(nameof(collector));
            }

            var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
            {
                Name     = entity.Name,
                Comments =
                {
                    Body = entity.Comments
                }
            };

            ReadInputParameters(calculation.InputParameters, entity, collector);
            ReadOutput(calculation, entity);

            return(calculation);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Creates a <see cref="WaveImpactAsphaltCoverWaveConditionsCalculationEntity"/> based on the information of the
        /// <see cref="WaveImpactAsphaltCoverWaveConditionsCalculation"/>.
        /// </summary>
        /// <param name="calculation">The calculation to create a database entity for.</param>
        /// <param name="registry">The object keeping track of create operations.</param>
        /// <param name="order">The index at which <paramref name="calculation"/> resides within its parent.</param>
        /// <returns>A new <see cref="WaveImpactAsphaltCoverWaveConditionsCalculationEntity"/>.</returns>
        /// <exception cref="ArgumentNullException">Thrown when any parameter is <c>null</c>.</exception>
        internal static WaveImpactAsphaltCoverWaveConditionsCalculationEntity Create(this WaveImpactAsphaltCoverWaveConditionsCalculation calculation,
                                                                                     PersistenceRegistry registry, int order)
        {
            if (calculation == null)
            {
                throw new ArgumentNullException(nameof(calculation));
            }

            if (registry == null)
            {
                throw new ArgumentNullException(nameof(registry));
            }

            var entity = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity
            {
                Order    = order,
                Name     = calculation.Name.DeepClone(),
                Comments = calculation.Comments.Body.DeepClone()
            };

            SetInputParameters(entity, calculation.InputParameters, registry);
            AddEntityForWaveImpactAsphaltCoverWaveConditionsOutput(calculation, entity);

            return(entity);
        }
Exemplo n.º 5
0
        public void Create_CalculationWithNaNProperties_ReturnCalculationEntity()
        {
            // Setup
            var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
            {
                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
            WaveImpactAsphaltCoverWaveConditionsCalculationEntity 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.º 6
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 WaveImpactAsphaltCoverWaveConditionsCalculation
            {
                InputParameters =
                {
                    CalculationsTargetProbability = hydraulicCalculations
                }
            };

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

            // Assert
            Assert.AreSame(hydraulicCalculationsEntity, entity.HydraulicLocationCalculationForTargetProbabilityCollectionEntity);
        }
Exemplo n.º 7
0
        public void Create_GroupWithChildWaveImpactAsphaltCoverWaveConditionsCalculationsAndChildCalculationGroups_CreateEntities()
        {
            // Setup
            var group = new CalculationGroup
            {
                Children =
                {
                    new CalculationGroup
                    {
                        Name = "A"
                    },
                    new WaveImpactAsphaltCoverWaveConditionsCalculation
                    {
                        Name = "B"
                    },
                    new CalculationGroup
                    {
                        Name = "C"
                    },
                    new WaveImpactAsphaltCoverWaveConditionsCalculation
                    {
                        Name = "D"
                    }
                }
            };

            var registry = new PersistenceRegistry();

            // Call
            CalculationGroupEntity entity = group.Create(registry, 0);

            // Assert
            CalculationGroupEntity[] childGroupEntities = entity.CalculationGroupEntity1.ToArray();
            WaveImpactAsphaltCoverWaveConditionsCalculationEntity[] childCalculationEntities = entity.WaveImpactAsphaltCoverWaveConditionsCalculationEntities.ToArray();
            Assert.AreEqual(2, childGroupEntities.Length);
            Assert.AreEqual(2, childCalculationEntities.Length);

            CalculationGroupEntity childEntity1 = childGroupEntities[0];

            Assert.AreEqual("A", childEntity1.Name);
            Assert.AreEqual(0, childEntity1.Order);
            CollectionAssert.IsEmpty(childEntity1.CalculationGroupEntity1);

            WaveImpactAsphaltCoverWaveConditionsCalculationEntity childEntity2 = childCalculationEntities[0];

            Assert.AreEqual("B", childEntity2.Name);
            Assert.AreEqual(1, childEntity2.Order);

            CalculationGroupEntity childEntity3 = childGroupEntities[1];

            Assert.AreEqual("C", childEntity3.Name);
            Assert.AreEqual(2, childEntity3.Order);
            CollectionAssert.IsEmpty(childEntity3.CalculationGroupEntity1);

            WaveImpactAsphaltCoverWaveConditionsCalculationEntity childEntity4 = childCalculationEntities[1];

            Assert.AreEqual("D", childEntity4.Name);
            Assert.AreEqual(3, childEntity4.Order);
        }
Exemplo n.º 8
0
 private static void AddEntityForWaveImpactAsphaltCoverWaveConditionsOutput(WaveImpactAsphaltCoverWaveConditionsCalculation calculation,
                                                                            WaveImpactAsphaltCoverWaveConditionsCalculationEntity entity)
 {
     if (calculation.HasOutput)
     {
         var i = 0;
         foreach (WaveConditionsOutput waveConditionsOutput in calculation.Output.Items)
         {
             entity.WaveImpactAsphaltCoverWaveConditionsOutputEntities.Add(waveConditionsOutput.CreateWaveImpactAsphaltCoverWaveConditionsOutputEntity(i++));
         }
     }
 }
        public void Read_CollectorIsNull_ThrowArgumentNullException()
        {
            // Setup
            var entity = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity();

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

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

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

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

            var registry = new PersistenceRegistry();

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

            // Assert
            WaveConditionsInput 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.WaterLevelType), entity.WaterLevelType);

            Assert.AreEqual(order, entity.Order);
            Assert.IsNull(entity.CalculationGroupEntity);
            CollectionAssert.IsEmpty(entity.WaveImpactAsphaltCoverWaveConditionsOutputEntities);
            Assert.IsNull(entity.ForeshoreProfileEntity);
            Assert.IsNull(entity.HydraulicLocationEntity);
            Assert.IsNull(entity.HydraulicLocationCalculationForTargetProbabilityCollectionEntity);
        }
        public void Read_EntityWithHydraulicBoundaryLocationNotYetInCollector_CalculationWithCreatedHydraulicBoundaryLocationAndRegisteredNewEntities()
        {
            // Setup
            HydraulicLocationEntity hydraulicLocationEntity = HydraulicLocationEntityTestFactory.CreateHydraulicLocationEntity();
            var entity = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity
            {
                HydraulicLocationEntity = hydraulicLocationEntity
            };

            var collector = new ReadConversionCollector();

            // Call
            entity.Read(collector);

            // Assert
            Assert.IsTrue(collector.Contains(hydraulicLocationEntity));
        }
Exemplo n.º 12
0
        public void Create_HasForeshoreProfile_EntityHasForeshoreProfileEntity()
        {
            // Setup
            var registry    = new PersistenceRegistry();
            var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
            {
                InputParameters =
                {
                    ForeshoreProfile = new TestForeshoreProfile()
                }
            };

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

            // Assert
            Assert.IsNotNull(entity.ForeshoreProfileEntity);
        }
        public void Read_EntityWithHydraulicBoundaryLocationInCollector_CalculationHasAlreadyReadHydraulicBoundaryLocation()
        {
            // Setup
            var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "A", 1.1, 2.2);
            var hydraulicLocationEntity   = new HydraulicLocationEntity();
            var entity = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity
            {
                HydraulicLocationEntity = hydraulicLocationEntity
            };

            var collector = new ReadConversionCollector();

            collector.Read(hydraulicLocationEntity, hydraulicBoundaryLocation);

            // Call
            WaveImpactAsphaltCoverWaveConditionsCalculation calculation = entity.Read(collector);

            // Assert
            Assert.AreSame(hydraulicBoundaryLocation, calculation.InputParameters.HydraulicBoundaryLocation);
        }
        public void Read_EntityWithHydraulicBoundaryLocationCalculationsForTargetProbabilityInCollector_CalculationHasAlreadyReadHydraulicBoundaryLocationCalculationsForTargetProbability()
        {
            // Setup
            var hydraulicBoundaryLocationCalculationsForTargetProbability = new HydraulicBoundaryLocationCalculationsForTargetProbability(0.05);
            HydraulicLocationCalculationForTargetProbabilityCollectionEntity calculationForTargetProbabilityCollectionEntity =
                HydraulicLocationCalculationForTargetProbabilityCollectionEntityTestFactory.CreateHydraulicLocationCalculationForTargetProbabilityCollectionEntity();
            var entity = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity
            {
                HydraulicLocationCalculationForTargetProbabilityCollectionEntity = calculationForTargetProbabilityCollectionEntity
            };

            var collector = new ReadConversionCollector();

            collector.Read(calculationForTargetProbabilityCollectionEntity, hydraulicBoundaryLocationCalculationsForTargetProbability);

            // Call
            WaveImpactAsphaltCoverWaveConditionsCalculation calculation = entity.Read(collector);

            // Assert
            Assert.AreSame(hydraulicBoundaryLocationCalculationsForTargetProbability, calculation.InputParameters.CalculationsTargetProbability);
        }
Exemplo n.º 15
0
        private static void ReadInputParameters(WaveConditionsInput inputParameters,
                                                WaveImpactAsphaltCoverWaveConditionsCalculationEntity entity,
                                                ReadConversionCollector collector)
        {
            inputParameters.ForeshoreProfile              = GetDikeProfileValue(entity.ForeshoreProfileEntity, collector);
            inputParameters.HydraulicBoundaryLocation     = GetHydraulicBoundaryLocationValue(entity.HydraulicLocationEntity, collector);
            inputParameters.CalculationsTargetProbability = GetHydraulicBoundaryLocationCalculationsForTargetProbabilityValue(
                entity.HydraulicLocationCalculationForTargetProbabilityCollectionEntity, collector);

            inputParameters.Orientation              = (RoundedDouble)entity.Orientation.ToNullAsNaN();
            inputParameters.UseForeshore             = Convert.ToBoolean(entity.UseForeshore);
            inputParameters.UseBreakWater            = Convert.ToBoolean(entity.UseBreakWater);
            inputParameters.BreakWater.Height        = (RoundedDouble)entity.BreakWaterHeight.ToNullAsNaN();
            inputParameters.BreakWater.Type          = (BreakWaterType)entity.BreakWaterType;
            inputParameters.UpperBoundaryRevetment   = (RoundedDouble)entity.UpperBoundaryRevetment.ToNullAsNaN();
            inputParameters.LowerBoundaryRevetment   = (RoundedDouble)entity.LowerBoundaryRevetment.ToNullAsNaN();
            inputParameters.UpperBoundaryWaterLevels = (RoundedDouble)entity.UpperBoundaryWaterLevels.ToNullAsNaN();
            inputParameters.LowerBoundaryWaterLevels = (RoundedDouble)entity.LowerBoundaryWaterLevels.ToNullAsNaN();
            inputParameters.StepSize       = (WaveConditionsInputStepSize)entity.StepSize;
            inputParameters.WaterLevelType = (WaveConditionsInputWaterLevelType)entity.WaterLevelType;
        }
Exemplo n.º 16
0
        public void Create_HasHydraulicLocationEntity_EntityHasHydraulicLocationEntity()
        {
            // Setup
            var hydraulicBoundaryLocation = new HydraulicBoundaryLocation(1, "A", 2.3, 4.5);

            var registry = new PersistenceRegistry();
            HydraulicLocationEntity hydraulicLocationEntity = hydraulicBoundaryLocation.Create(registry, 0);

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

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

            // Assert
            Assert.AreSame(hydraulicLocationEntity, entity.HydraulicLocationEntity);
        }
Exemplo n.º 17
0
        public void Create_StringPropertiesDoNotShareReference()
        {
            // Setup
            const string name        = "A";
            const string comments    = "B";
            var          calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
            {
                Name     = name,
                Comments =
                {
                    Body = comments
                }
            };

            var registry = new PersistenceRegistry();

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

            // Assert
            TestHelper.AssertAreEqualButNotSame(calculation.Name, entity.Name);
            TestHelper.AssertAreEqualButNotSame(calculation.Comments.Body, entity.Comments);
        }
        public void Read_EntityWithForeshoreProfileInCollector_CalculationHasAlreadyReadForeshoreProfile()
        {
            // Setup
            var foreshoreProfile       = new TestForeshoreProfile();
            var foreshoreProfileEntity = new ForeshoreProfileEntity
            {
                GeometryXml = new Point2DCollectionXmlSerializer().ToXml(Enumerable.Empty <Point2D>())
            };
            var entity = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity
            {
                ForeshoreProfileEntity = foreshoreProfileEntity
            };

            var collector = new ReadConversionCollector();

            collector.Read(foreshoreProfileEntity, foreshoreProfile);

            // Call
            WaveImpactAsphaltCoverWaveConditionsCalculation calculation = entity.Read(collector);

            // Assert
            Assert.AreSame(foreshoreProfile, calculation.InputParameters.ForeshoreProfile);
        }
        public void Read_EntityWithCalculationOutputEntity_CalculationWithOutput()
        {
            // Setup
            const double outputALevel = 5.4;
            const double outputBLevel = 2.3;
            var          entity       = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity
            {
                WaveImpactAsphaltCoverWaveConditionsOutputEntities =
                {
                    new WaveImpactAsphaltCoverWaveConditionsOutputEntity
                    {
                        CalculationConvergence = Convert.ToByte(CalculationConvergence.NotCalculated),
                        WaterLevel             = outputBLevel,
                        Order = 1
                    },
                    new WaveImpactAsphaltCoverWaveConditionsOutputEntity
                    {
                        CalculationConvergence = Convert.ToByte(CalculationConvergence.NotCalculated),
                        WaterLevel             = outputALevel,
                        Order = 0
                    }
                }
            };

            var collector = new ReadConversionCollector();

            // Call
            WaveImpactAsphaltCoverWaveConditionsCalculation calculation = entity.Read(collector);

            // Assert
            Assert.IsNotNull(calculation.Output);
            Assert.AreEqual(2, calculation.Output.Items.Count());
            double accuracy = calculation.Output.Items.ElementAt(0).WaterLevel.GetAccuracy();

            Assert.AreEqual(outputALevel, calculation.Output.Items.ElementAt(0).WaterLevel, accuracy);
            Assert.AreEqual(outputBLevel, calculation.Output.Items.ElementAt(1).WaterLevel, accuracy);
        }
        public void Read_EntityWithForeshoreProfileNotYetInCollector_CalculationWithCreatedForeshoreProfileAndRegisteredNewEntities()
        {
            // Setup
            const string id = "profile";
            var          foreshoreProfileEntity = new ForeshoreProfileEntity
            {
                Id          = id,
                GeometryXml = new Point2DCollectionXmlSerializer().ToXml(Enumerable.Empty <Point2D>())
            };

            var entity = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity
            {
                ForeshoreProfileEntity = foreshoreProfileEntity
            };

            var collector = new ReadConversionCollector();

            // Call
            WaveImpactAsphaltCoverWaveConditionsCalculation calculation = entity.Read(collector);

            // Assert
            Assert.IsTrue(collector.Contains(foreshoreProfileEntity));
            CollectionAssert.AreEqual(id, calculation.InputParameters.ForeshoreProfile.Id);
        }
Exemplo n.º 21
0
        public void Create_HasCalculationOutputs_EntityHasOrderedCalculationOutputEntity()
        {
            // Setup
            var registry    = new PersistenceRegistry();
            var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
            {
                Output = new WaveImpactAsphaltCoverWaveConditionsOutput(new[]
                {
                    new TestWaveConditionsOutput(),
                    new TestWaveConditionsOutput()
                })
            };

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

            // Assert
            Assert.AreEqual(2, entity.WaveImpactAsphaltCoverWaveConditionsOutputEntities.Count);
            Assert.AreEqual(new[]
            {
                0,
                1
            }, entity.WaveImpactAsphaltCoverWaveConditionsOutputEntities.Select(oe => oe.Order));
        }
Exemplo n.º 22
0
 private static void ReadOutput(WaveImpactAsphaltCoverWaveConditionsCalculation calculation, WaveImpactAsphaltCoverWaveConditionsCalculationEntity entity)
 {
     if (entity.WaveImpactAsphaltCoverWaveConditionsOutputEntities.Any())
     {
         calculation.Output = new WaveImpactAsphaltCoverWaveConditionsOutput(entity.WaveImpactAsphaltCoverWaveConditionsOutputEntities
                                                                             .OrderBy(oe => oe.Order)
                                                                             .Select(oe => oe.Read())
                                                                             .ToArray());
     }
 }
        public void Read_ValidEntity_ReturnCalculation()
        {
            // Setup
            const string name     = "Calculation Name";
            const string comments = "Calculation Comment";

            var          random                   = new Random(21);
            double       orientation              = random.NextDouble();
            bool         useBreakWater            = random.NextBoolean();
            var          breakWaterType           = random.NextEnumValue <BreakWaterType>();
            double       breakWaterHeight         = random.NextDouble();
            bool         useForeshore             = random.NextBoolean();
            const double lowerBoundaryRevetment   = 3.58;
            const double upperBoundaryRevetment   = 6.10;
            const double lowerBoundaryWaterLevels = 3.40;
            const double upperBoundaryWaterLevels = 5.88;
            var          stepSize                 = random.NextEnumValue <WaveConditionsInputStepSize>();
            var          waterLevelType           = random.NextEnumValue <WaveConditionsInputWaterLevelType>();

            var entity = new WaveImpactAsphaltCoverWaveConditionsCalculationEntity
            {
                Name                     = name,
                Comments                 = comments,
                UseBreakWater            = Convert.ToByte(useBreakWater),
                BreakWaterType           = Convert.ToByte(breakWaterType),
                BreakWaterHeight         = breakWaterHeight,
                UseForeshore             = Convert.ToByte(useForeshore),
                Orientation              = orientation,
                UpperBoundaryRevetment   = upperBoundaryRevetment,
                LowerBoundaryRevetment   = lowerBoundaryRevetment,
                UpperBoundaryWaterLevels = upperBoundaryWaterLevels,
                LowerBoundaryWaterLevels = lowerBoundaryWaterLevels,
                StepSize                 = Convert.ToByte(stepSize),
                WaterLevelType           = Convert.ToByte(waterLevelType)
            };

            var collector = new ReadConversionCollector();

            // Call
            WaveImpactAsphaltCoverWaveConditionsCalculation calculation = entity.Read(collector);

            // Assert
            Assert.AreEqual(name, calculation.Name);
            Assert.AreEqual(comments, calculation.Comments.Body);

            WaveConditionsInput calculationInput = calculation.InputParameters;

            Assert.AreEqual(useBreakWater, calculationInput.UseBreakWater);
            Assert.AreEqual(breakWaterType, calculationInput.BreakWater.Type);
            RoundedDoubleTestHelper.AssertRoundedDouble(breakWaterHeight, calculationInput.BreakWater.Height);
            Assert.AreEqual(useForeshore, calculationInput.UseForeshore);
            RoundedDoubleTestHelper.AssertRoundedDouble(orientation, calculationInput.Orientation);
            RoundedDoubleTestHelper.AssertRoundedDouble(upperBoundaryRevetment, calculationInput.UpperBoundaryRevetment);
            RoundedDoubleTestHelper.AssertRoundedDouble(lowerBoundaryRevetment, calculationInput.LowerBoundaryRevetment);
            RoundedDoubleTestHelper.AssertRoundedDouble(upperBoundaryWaterLevels, calculationInput.UpperBoundaryWaterLevels);
            RoundedDoubleTestHelper.AssertRoundedDouble(lowerBoundaryWaterLevels, calculationInput.LowerBoundaryWaterLevels);
            Assert.AreEqual(stepSize, calculationInput.StepSize);
            Assert.AreEqual(waterLevelType, calculationInput.WaterLevelType);

            Assert.IsNull(calculationInput.HydraulicBoundaryLocation);
            Assert.IsNull(calculationInput.ForeshoreProfile);
            Assert.IsNull(calculationInput.CalculationsTargetProbability);
            Assert.IsNull(calculation.Output);
        }