Example #1
0
 private static void GenerateWaveImpactAsphaltCoverWaveConditionsCalculations(IEnumerable <HydraulicBoundaryLocation> hydraulicBoundaryLocations,
                                                                              List <ICalculationBase> calculationCollection,
                                                                              NormativeProbabilityType normativeProbabilityType)
 {
     WaveImpactAsphaltCoverWaveConditionsCalculationConfigurationHelper.AddCalculationsFromLocations(
         hydraulicBoundaryLocations,
         calculationCollection,
         normativeProbabilityType);
 }
        public void AddCalculationsFromLocations_CalculationsIsNull_ThrowsArgumentNullException()
        {
            // Setup
            var random = new Random(21);
            IEnumerable <HydraulicBoundaryLocation> locations = Enumerable.Empty <HydraulicBoundaryLocation>();

            // Call
            void Call() => WaveImpactAsphaltCoverWaveConditionsCalculationConfigurationHelper.AddCalculationsFromLocations(locations, null, random.NextEnumValue <NormativeProbabilityType>());

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

            Assert.AreEqual("calculations", paramName);
        }
        public void AddCalculationsFromLocations_LocationsIsNull_ThrowsArgumentNullException()
        {
            // Setup
            var random       = new Random(21);
            var calculations = new List <ICalculationBase>();

            // Call
            void Call() => WaveImpactAsphaltCoverWaveConditionsCalculationConfigurationHelper.AddCalculationsFromLocations(null, calculations, random.NextEnumValue <NormativeProbabilityType>());

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

            Assert.AreEqual("locations", paramName);
        }
        public void AddCalculationsFromLocations_EmptyCollections_ReturnsEmptyList()
        {
            // Setup
            var random = new Random(21);
            IEnumerable <HydraulicBoundaryLocation> locations = Enumerable.Empty <HydraulicBoundaryLocation>();
            var calculationBases = new List <ICalculationBase>();

            // Call
            WaveImpactAsphaltCoverWaveConditionsCalculationConfigurationHelper.AddCalculationsFromLocations(locations,
                                                                                                            calculationBases,
                                                                                                            random.NextEnumValue <NormativeProbabilityType>());

            // Assert
            CollectionAssert.IsEmpty(calculationBases);
        }
        public void AddCalculationsFromLocations_MultipleCalculationsAndDuplicateNameInCalculationBase_ReturnsUniquelyNamedCalculationsWithCorrectInputSet(
            NormativeProbabilityType normativeProbabilityType,
            WaveConditionsInputWaterLevelType expectedWaveConditionsInputWaterLevelType)
        {
            // Setup
            const string name      = "name";
            var          locations = new[]
            {
                new HydraulicBoundaryLocation(1, name, 1, 1),
                new HydraulicBoundaryLocation(2, name, 2, 2)
            };
            var calculationBases = new List <ICalculationBase>
            {
                new WaveImpactAsphaltCoverWaveConditionsCalculation
                {
                    Name = name
                }
            };

            // Call
            WaveImpactAsphaltCoverWaveConditionsCalculationConfigurationHelper.AddCalculationsFromLocations(locations, calculationBases, normativeProbabilityType);

            // Assert
            Assert.AreEqual(3, calculationBases.Count);
            var firstCalculation = (WaveImpactAsphaltCoverWaveConditionsCalculation)calculationBases.ElementAt(1);

            Assert.AreEqual($"{name} (1)", firstCalculation.Name);
            WaveConditionsInput firstCalculationInput = firstCalculation.InputParameters;

            Assert.AreEqual(locations[0], firstCalculationInput.HydraulicBoundaryLocation);
            Assert.AreEqual(expectedWaveConditionsInputWaterLevelType, firstCalculationInput.WaterLevelType);

            var secondCalculation = (WaveImpactAsphaltCoverWaveConditionsCalculation)calculationBases.ElementAt(2);

            Assert.AreEqual($"{name} (2)", secondCalculation.Name);
            WaveConditionsInput secondCalculationInput = secondCalculation.InputParameters;

            Assert.AreSame(locations[1], secondCalculationInput.HydraulicBoundaryLocation);
            Assert.AreEqual(expectedWaveConditionsInputWaterLevelType, secondCalculationInput.WaterLevelType);
        }