private static IEnumerable <ExportableWaveConditions> CreateExportableWaveConditionsCollection(IEnumerable <WaveImpactAsphaltCoverWaveConditionsCalculation> calculations,
                                                                                                       Func <WaveConditionsInput, string> getTargetProbabilityFunc)
        {
            if (calculations == null)
            {
                throw new ArgumentNullException(nameof(calculations));
            }

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

            var exportableWaveConditions = new List <ExportableWaveConditions>();

            IEnumerable <WaveImpactAsphaltCoverWaveConditionsCalculation> exportableCalculations =
                calculations.Where(c => c.HasOutput && c.InputParameters.HydraulicBoundaryLocation != null);

            foreach (WaveImpactAsphaltCoverWaveConditionsCalculation calculation in exportableCalculations)
            {
                exportableWaveConditions.AddRange(
                    ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection(
                        calculation.Name, calculation.InputParameters, calculation.Output.Items, CoverType.Asphalt, getTargetProbabilityFunc));
            }

            return(exportableWaveConditions);
        }
예제 #2
0
        private static IEnumerable<ExportableWaveConditions> CreateExportableWaveConditions(IEnumerable<StabilityStoneCoverWaveConditionsCalculation> exportableCalculations,
                                                                                            Func<WaveConditionsInput, string> getTargetProbabilityFunc)
        {
            var exportableWaveConditions = new List<ExportableWaveConditions>();
            foreach (StabilityStoneCoverWaveConditionsCalculation calculation in exportableCalculations)
            {
                StabilityStoneCoverWaveConditionsCalculationType calculationType = calculation.InputParameters.CalculationType;
                if (calculationType == StabilityStoneCoverWaveConditionsCalculationType.Both
                    || calculationType == StabilityStoneCoverWaveConditionsCalculationType.Blocks)
                {
                    exportableWaveConditions.AddRange(
                        ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection(
                            calculation.Name, calculation.InputParameters, calculation.Output.BlocksOutput, CoverType.StoneCoverBlocks, getTargetProbabilityFunc));
                }

                if (calculationType == StabilityStoneCoverWaveConditionsCalculationType.Both
                    || calculationType == StabilityStoneCoverWaveConditionsCalculationType.Columns)
                {
                    exportableWaveConditions.AddRange(
                        ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection(
                            calculation.Name, calculation.InputParameters, calculation.Output.ColumnsOutput, CoverType.StoneCoverColumns, getTargetProbabilityFunc));
                }
            }

            return exportableWaveConditions;
        }
예제 #3
0
        public void CreateExportableWaveConditionsCollectionWithWaveConditionsInput_GetTargetProbabilityFuncNull_ThrowArgumentNullException()
        {
            // Call
            void Call() => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("aName", new WaveConditionsInput(),
                                                                                                    waveConditionsOutputCollection, CoverType.Asphalt, null);

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("getTargetProbabilityFunc", exception.ParamName);
        }
예제 #4
0
        public void CreateExportableWaveConditionsCollectionWithWaveConditionsInput_CoverTypeNull_ThrowArgumentNullException()
        {
            // Call
            void Call() => ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("aName", new WaveConditionsInput(),
                                                                                                    waveConditionsOutputCollection, null, i => "1/100");

            // Assert
            var exception = Assert.Throws <ArgumentNullException>(Call);

            Assert.AreEqual("coverType", exception.ParamName);
        }
        private static IEnumerable <ExportableWaveConditions> CreateExportableWaveConditionsCollection(IEnumerable <GrassCoverErosionOutwardsWaveConditionsCalculation> calculations,
                                                                                                       Func <WaveConditionsInput, string> getTargetProbabilityFunc)
        {
            if (calculations == null)
            {
                throw new ArgumentNullException(nameof(calculations));
            }

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

            var exportableWaveConditions = new List <ExportableWaveConditions>();

            IEnumerable <GrassCoverErosionOutwardsWaveConditionsCalculation> exportableCalculations =
                calculations.Where(c => c.HasOutput && c.InputParameters.HydraulicBoundaryLocation != null);

            foreach (GrassCoverErosionOutwardsWaveConditionsCalculation calculation in exportableCalculations)
            {
                GrassCoverErosionOutwardsWaveConditionsCalculationType calculationType = calculation.InputParameters.CalculationType;

                if (calculationType == GrassCoverErosionOutwardsWaveConditionsCalculationType.WaveRunUpAndWaveImpact ||
                    calculationType == GrassCoverErosionOutwardsWaveConditionsCalculationType.WaveRunUp ||
                    calculationType == GrassCoverErosionOutwardsWaveConditionsCalculationType.WaveRunUpAndWaveImpactWithWaveDirection ||
                    calculationType == GrassCoverErosionOutwardsWaveConditionsCalculationType.All)
                {
                    exportableWaveConditions.AddRange(
                        ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection(
                            calculation.Name, calculation.InputParameters, calculation.Output.WaveRunUpOutput, CoverType.GrassWaveRunUp, getTargetProbabilityFunc));
                }

                if (calculationType == GrassCoverErosionOutwardsWaveConditionsCalculationType.WaveRunUpAndWaveImpact ||
                    calculationType == GrassCoverErosionOutwardsWaveConditionsCalculationType.WaveImpact ||
                    calculationType == GrassCoverErosionOutwardsWaveConditionsCalculationType.All)
                {
                    exportableWaveConditions.AddRange(
                        ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection(
                            calculation.Name, calculation.InputParameters, calculation.Output.WaveImpactOutput, CoverType.GrassWaveImpact, getTargetProbabilityFunc));
                }

                if (calculationType == GrassCoverErosionOutwardsWaveConditionsCalculationType.WaveImpactWithWaveDirection ||
                    calculationType == GrassCoverErosionOutwardsWaveConditionsCalculationType.WaveRunUpAndWaveImpactWithWaveDirection ||
                    calculationType == GrassCoverErosionOutwardsWaveConditionsCalculationType.All)
                {
                    exportableWaveConditions.AddRange(
                        ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection(
                            calculation.Name, calculation.InputParameters, calculation.Output.WaveImpactWithWaveDirectionOutput, CoverType.GrassWaveImpactWithWaveDirection, getTargetProbabilityFunc));
                }
            }

            return(exportableWaveConditions);
        }
예제 #6
0
        public void CreateExportableWaveConditionsCollectionWithWaveConditionsInput_ValidDataWithCoverType_ReturnsValidCollection_ValidDataWithCoverType_ReturnsValidCollection(CoverType coverType)
        {
            // Setup
            var waveConditionsInput = new WaveConditionsInput
            {
                HydraulicBoundaryLocation = new HydraulicBoundaryLocation(0, "hblName", 1.0, 8.0),
                ForeshoreProfile          = new TestForeshoreProfile(),
                UseForeshore = true
            };

            // Call
            ExportableWaveConditions[] exportableWaveConditionsCollection =
                ExportableWaveConditionsFactory.CreateExportableWaveConditionsCollection("ewcName",
                                                                                         waveConditionsInput,
                                                                                         waveConditionsOutputCollection,
                                                                                         coverType,
                                                                                         i => "1/100").ToArray();

            // Assert
            Assert.AreEqual(1, exportableWaveConditionsCollection.Length);
            ExportableWaveConditions exportableWaveConditions = exportableWaveConditionsCollection[0];

            Assert.AreEqual("ewcName", exportableWaveConditions.CalculationName);
            Assert.AreEqual("hblName", exportableWaveConditions.LocationName);
            Assert.AreEqual(1.0, exportableWaveConditions.LocationXCoordinate);
            Assert.AreEqual(8.0, exportableWaveConditions.LocationYCoordinate);
            Assert.AreEqual("id", exportableWaveConditions.ForeshoreId);
            Assert.AreEqual(false, exportableWaveConditions.UseBreakWater);
            Assert.AreEqual(true, exportableWaveConditions.UseForeshore);
            Assert.AreEqual(coverType, exportableWaveConditions.CoverType);
            Assert.AreEqual("1/100", exportableWaveConditions.TargetProbability);
            Assert.AreEqual(2, exportableWaveConditions.WaterLevel.NumberOfDecimalPlaces);
            Assert.AreEqual(2, exportableWaveConditions.WaveHeight.NumberOfDecimalPlaces);
            Assert.AreEqual(2, exportableWaveConditions.WavePeriod.NumberOfDecimalPlaces);
            Assert.AreEqual(2, exportableWaveConditions.WaveAngle.NumberOfDecimalPlaces);
            Assert.AreEqual(waveConditionsOutput.WaterLevel, exportableWaveConditions.WaterLevel);
            Assert.AreEqual(waveConditionsOutput.WaveHeight, exportableWaveConditions.WaveHeight);
            Assert.AreEqual(waveConditionsOutput.WavePeakPeriod, exportableWaveConditions.WavePeriod);
            Assert.AreEqual(waveConditionsOutput.WaveAngle, exportableWaveConditions.WaveAngle);
            Assert.AreEqual(waveConditionsOutput.WaveDirection, exportableWaveConditions.WaveDirection);
        }