public void SetWaterLevelType_WithWaveConditionsInputAndVariousNormativeProbabilityTypes_SetsWaterLevelType(
            NormativeProbabilityType normativeProbabilityType,
            WaveConditionsInputWaterLevelType expectedWaveConditionsInputWaterLevelType)
        {
            // Setup
            var waveConditionsInput = new WaveConditionsInput();

            // Call
            WaveConditionsInputHelper.SetWaterLevelType(waveConditionsInput, normativeProbabilityType);

            // Assert
            Assert.AreEqual(expectedWaveConditionsInputWaterLevelType, waveConditionsInput.WaterLevelType);
        }
        public void SetWaterLevelType_WaveConditionsInputNull_ThrowsArgumentNullException()
        {
            // Setup
            var random = new Random(21);

            // Call
            void Call() => WaveConditionsInputHelper.SetWaterLevelType(null, random.NextEnumValue <NormativeProbabilityType>());

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

            Assert.AreEqual("waveConditionsInput", exception.ParamName);
        }
        public void SetWaterLevelType_InvalidNormativeProbabilityType_ThrowsInvalidEnumArgumentException()
        {
            // Setup
            const NormativeProbabilityType normativeProbabilityType = (NormativeProbabilityType)99;

            // Call
            void Call() => WaveConditionsInputHelper.SetWaterLevelType(new WaveConditionsInput(), normativeProbabilityType);

            // Assert
            var expectedMessage = $"The value of argument 'normativeProbabilityType' ({normativeProbabilityType}) is invalid for Enum type '{nameof(NormativeProbabilityType)}'.";
            var exception       = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(Call, expectedMessage);

            Assert.AreEqual("normativeProbabilityType", exception.ParamName);
        }
Exemplo n.º 4
0
        private static void AddWaveConditionsCalculation(WaveImpactAsphaltCoverCalculationGroupContext nodeData)
        {
            var calculation = new WaveImpactAsphaltCoverWaveConditionsCalculation
            {
                Name = NamingHelper.GetUniqueName(nodeData.WrappedData.Children,
                                                  RiskeerCommonDataResources.Calculation_DefaultName,
                                                  c => c.Name)
            };

            WaveConditionsInputHelper.SetWaterLevelType(calculation.InputParameters,
                                                        nodeData.AssessmentSection.FailureMechanismContribution.NormativeProbabilityType);
            nodeData.WrappedData.Children.Add(calculation);
            nodeData.WrappedData.NotifyObservers();
        }
Exemplo n.º 5
0
        /// <summary>
        /// Creates a calculation and sets the <paramref name="hydraulicBoundaryLocation"/>
        /// and the water level type on its input.
        /// </summary>
        /// <param name="hydraulicBoundaryLocation">The <see cref="HydraulicBoundaryLocation"/> to set.</param>
        /// <param name="calculations">The list of calculations to base the calculation name from.</param>
        /// <param name="normativeProbabilityType">The <see cref="NormativeProbabilityType"/> to base the water level type input on.</param>
        /// <returns>An <see cref="ICalculationBase"/> representing a stability stone cover calculation.</returns>
        /// <exception cref="InvalidEnumArgumentException">Thrown when <paramref name="normativeProbabilityType"/> is an invalid value.</exception>
        /// <exception cref="NotSupportedException">Thrown when <paramref name="normativeProbabilityType"/> is a valid value,
        /// but unsupported.</exception>
        private static ICalculationBase CreateStabilityStoneCoverWaveConditionsCalculation(
            HydraulicBoundaryLocation hydraulicBoundaryLocation,
            IEnumerable <ICalculationBase> calculations,
            NormativeProbabilityType normativeProbabilityType)
        {
            string nameBase    = hydraulicBoundaryLocation.Name;
            var    calculation = new StabilityStoneCoverWaveConditionsCalculation
            {
                Name            = NamingHelper.GetUniqueName(calculations, nameBase, c => c.Name),
                InputParameters =
                {
                    HydraulicBoundaryLocation = hydraulicBoundaryLocation
                }
            };

            WaveConditionsInputHelper.SetWaterLevelType(calculation.InputParameters, normativeProbabilityType);
            return(calculation);
        }