Example #1
0
        public void ValidateProbability_AllowNaN_DoesNotThrow()
        {
            // Call
            TestDelegate call = () => ProbabilityHelper.ValidateProbability(double.NaN, "A", true);

            // Assert
            Assert.DoesNotThrow(call);
        }
Example #2
0
        public void ValidateProbability_ValidProbability_DoesNotThrow(double probability)
        {
            // Call
            TestDelegate call = () => ProbabilityHelper.ValidateProbability(probability, "A");

            // Assert
            Assert.DoesNotThrow(call);
        }
Example #3
0
        public void ValidateProbability_InvalidProbability_ThrowsArgumentOutOfRangeException(double invalidProbabilityValue, string expectedParamName)
        {
            // Call
            TestDelegate call = () => ProbabilityHelper.ValidateProbability(invalidProbabilityValue, expectedParamName);

            // Assert
            const string message   = "Kans moet in het bereik [0,0, 1,0] liggen.";
            string       paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(call, message).ParamName;

            Assert.AreEqual(expectedParamName, paramName);
        }
Example #4
0
        public void ValidateProbability_WithCustomMessageAndAllowNaN_DoesNotThrow()
        {
            // Setup
            const string customMessage = "Test {0}";

            // Call
            TestDelegate call = () => ProbabilityHelper.ValidateProbability(double.NaN, "A", customMessage, true);

            // Assert
            Assert.DoesNotThrow(call);
        }
Example #5
0
        public void ValidateProbability_WithCustomMessageAndValidProbability_DoesNotThrow(double probability)
        {
            // Setup
            const string customMessage = "Test {0}";

            // Call
            TestDelegate call = () => ProbabilityHelper.ValidateProbability(probability, "A", customMessage);

            // Assert
            Assert.DoesNotThrow(call);
        }
Example #6
0
        public void ValidateProbability_WithCustomMessageAndInvalidProbability_ThrowsArgumentOutOfRangeException(double invalidProbabilityValue, string expectedParamName)
        {
            // Setup
            const string customMessage = "Test {0}";

            // Call
            TestDelegate call = () => ProbabilityHelper.ValidateProbability(invalidProbabilityValue, expectedParamName, customMessage);

            // Assert
            const string message   = "Test [0,0, 1,0]";
            string       paramName = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentOutOfRangeException>(call, message).ParamName;

            Assert.AreEqual(expectedParamName, paramName);
        }
Example #7
0
        public void ValidateProbability_WithInvalidCustomMessage_ThrowsArgumentException()
        {
            // Setup
            const string customMessage = "Test";

            // Call
            TestDelegate call = () => ProbabilityHelper.ValidateProbability(1.0, "value", customMessage);

            // Assert
            const string expectedMessage = "The custom message should have a insert location (\"{0}\") where the validity range is to be inserted.";
            string       paramName       = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <ArgumentException>(call, expectedMessage).ParamName;

            Assert.AreEqual("customMessage", paramName);
        }
Example #8
0
        /// <summary>
        /// Creates a new instance of <see cref="HydraulicLoadsOutput"/>.
        /// </summary>
        /// <param name="targetProbability">The target probability used during the calculation.</param>
        /// <param name="targetReliability">The reliability index used during the calculation.</param>
        /// <param name="calculatedProbability">The calculated probability.</param>
        /// <param name="calculatedReliability">The calculated reliability index.</param>
        /// <param name="calculationConvergence">The convergence status of the calculation.</param>
        /// <param name="generalResult">The general result with the fault tree illustration points.</param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="targetProbability"/>
        /// or <paramref name="calculatedProbability"/> falls outside the [0.0, 1.0] range and is not <see cref="double.NaN"/>.</exception>
        protected HydraulicLoadsOutput(double targetProbability, double targetReliability,
                                       double calculatedProbability, double calculatedReliability,
                                       CalculationConvergence calculationConvergence,
                                       GeneralResult <TopLevelFaultTreeIllustrationPoint> generalResult)
        {
            ProbabilityHelper.ValidateProbability(targetProbability, nameof(targetProbability), true);
            ProbabilityHelper.ValidateProbability(calculatedProbability, nameof(calculatedProbability), true);

            TargetProbability      = targetProbability;
            TargetReliability      = new RoundedDouble(5, targetReliability);
            CalculatedProbability  = calculatedProbability;
            CalculatedReliability  = new RoundedDouble(5, calculatedReliability);
            CalculationConvergence = calculationConvergence;
            GeneralResult          = generalResult;
        }
        /// <summary>
        /// Creates a new instance of <see cref="HydraulicBoundaryLocationCalculationOutput"/>.
        /// </summary>
        /// <param name="result">The calculation result.</param>
        /// <param name="targetProbability">The target probability used during the calculation.</param>
        /// <param name="targetReliability">The reliability index used during the calculation.</param>
        /// <param name="calculatedProbability">The calculated probability.</param>
        /// <param name="calculatedReliability">The calculated reliability.</param>
        /// <param name="calculationConvergence">The convergence status of the calculation.</param>
        /// <param name="generalResult">The general result of this output with sub mechanism illustration points.</param>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when <paramref name="targetProbability"/>
        /// or <paramref name="calculatedProbability"/> falls outside the [0.0, 1.0] range and is not <see cref="double.NaN"/>.</exception>
        public HydraulicBoundaryLocationCalculationOutput(double result,
                                                          double targetProbability,
                                                          double targetReliability,
                                                          double calculatedProbability,
                                                          double calculatedReliability,
                                                          CalculationConvergence calculationConvergence,
                                                          GeneralResult <TopLevelSubMechanismIllustrationPoint> generalResult)
        {
            ProbabilityHelper.ValidateProbability(targetProbability, nameof(targetProbability), true);
            ProbabilityHelper.ValidateProbability(calculatedProbability, nameof(calculatedProbability), true);

            Result = new RoundedDouble(2, result);

            TargetProbability      = targetProbability;
            TargetReliability      = new RoundedDouble(5, targetReliability);
            CalculatedProbability  = calculatedProbability;
            CalculatedReliability  = new RoundedDouble(5, calculatedReliability);
            CalculationConvergence = calculationConvergence;
            GeneralResult          = generalResult;
        }
        /// <summary>
        /// Creates a new instance of <see cref="DuneLocationCalculationOutput"/>.
        /// </summary>
        /// <param name="calculationConvergence">The convergence status of the calculation.</param>
        /// <param name="constructionProperties">The container for the properties for the <see cref="DuneLocationCalculationOutput"/>.</param>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="constructionProperties"/> is <c>null</c>.</exception>
        /// <exception cref="ArgumentOutOfRangeException">Thrown when <see cref="ConstructionProperties.TargetProbability"/>
        /// or <see cref="ConstructionProperties.CalculatedProbability"/> falls outside the [0.0, 1.0] range.</exception>
        public DuneLocationCalculationOutput(CalculationConvergence calculationConvergence, ConstructionProperties constructionProperties)
        {
            if (constructionProperties == null)
            {
                throw new ArgumentNullException(nameof(constructionProperties));
            }

            WaterLevel = new RoundedDouble(2, constructionProperties.WaterLevel);
            WaveHeight = new RoundedDouble(2, constructionProperties.WaveHeight);
            WavePeriod = new RoundedDouble(2, constructionProperties.WavePeriod);

            ProbabilityHelper.ValidateProbability(constructionProperties.TargetProbability, nameof(TargetProbability), true);
            ProbabilityHelper.ValidateProbability(constructionProperties.CalculatedProbability, nameof(CalculatedProbability), true);

            TargetProbability      = constructionProperties.TargetProbability;
            TargetReliability      = new RoundedDouble(5, constructionProperties.TargetReliability);
            CalculatedProbability  = constructionProperties.CalculatedProbability;
            CalculatedReliability  = new RoundedDouble(5, constructionProperties.CalculatedReliability);
            CalculationConvergence = calculationConvergence;
        }