Beispiel #1
0
        private static string CreateExpectedGraphNodeContent(string name, RoundedDouble beta)
        {
            RoundedDouble roundedBeta = beta.ToPrecision(5);

            return($"<text><bold>{name}</bold>{Environment.NewLine}" +
                   $"{Environment.NewLine}" +
                   $"Berekende kans = 1/6{Environment.NewLine}" +
                   $"Betrouwbaarheidsindex = {roundedBeta}</text>");
        }
Beispiel #2
0
        public void ToPrecision_VariousScenarios_ReturnRoundedDouble(int newPrecision, double expectedValue)
        {
            // Setup
            var original = new RoundedDouble(3, 1.236);

            // Call
            RoundedDouble convertedResult = original.ToPrecision(newPrecision);

            // Assert
            Assert.AreEqual(newPrecision, convertedResult.NumberOfDecimalPlaces);
            Assert.AreEqual(expectedValue, convertedResult.Value);
        }
Beispiel #3
0
        /// <summary>
        /// Tries to assign the grid x left and x right parameters to the <paramref name="grid"/>.
        /// </summary>
        /// <param name="gridConfiguration">The grid configuration read from the imported file.</param>
        /// <param name="grid">The calculation grid to configure.</param>
        /// <param name="calculationName">The name of the read calculation.</param>
        /// <returns><c>true</c> if no x left and x right was given, or when x left and x right
        /// are set to the <paramref name="grid"/>, <c>false</c> otherwise.</returns>
        private bool TrySetGridXLeftXRight(MacroStabilityInwardsGridConfiguration gridConfiguration,
                                           MacroStabilityInwardsGrid grid,
                                           string calculationName)
        {
            bool hasXLeftValue  = gridConfiguration.XLeft.HasValue;
            bool hasXRightValue = gridConfiguration.XRight.HasValue;

            if (!hasXLeftValue && !hasXRightValue)
            {
                return(true);
            }

            RoundedDouble xLeft = hasXLeftValue
                                      ? (RoundedDouble)gridConfiguration.XLeft.Value
                                      : RoundedDouble.NaN;

            RoundedDouble xRight = hasXRightValue
                                       ? (RoundedDouble)gridConfiguration.XRight.Value
                                       : RoundedDouble.NaN;

            try
            {
                grid.XLeft  = xLeft;
                grid.XRight = xRight;
            }
            catch (ArgumentException e)
            {
                Log.LogCalculationConversionError(string.Format(Resources.MacroStabilityInwardsCalculationConfigurationImporter_TrySetGridXLeftXRight_Combination_of_XLeft_0_and_XRight_1_invalid_Reason_2,
                                                                xLeft.ToPrecision(grid.XLeft.NumberOfDecimalPlaces),
                                                                xRight.ToPrecision(grid.XRight.NumberOfDecimalPlaces),
                                                                e.Message),
                                                  calculationName);

                return(false);
            }

            return(true);
        }
Beispiel #4
0
        /// <summary>
        /// Tries to assign the grid Z top and Z bottom parameters to the <paramref name="grid"/>.
        /// </summary>
        /// <param name="gridConfiguration">The grid configuration read from the imported file.</param>
        /// <param name="grid">The calculation grid to configure.</param>
        /// <param name="calculationName">The name of the read calculation.</param>
        /// <returns><c>true</c> if no z top and z bottom was given, or when z top and z bottom
        /// are set to the <paramref name="grid"/>, <c>false</c> otherwise.</returns>
        private bool TrySetGridZTopZBottom(MacroStabilityInwardsGridConfiguration gridConfiguration,
                                           MacroStabilityInwardsGrid grid,
                                           string calculationName)
        {
            bool hasZTopValue    = gridConfiguration.ZTop.HasValue;
            bool hasZBottomValue = gridConfiguration.ZBottom.HasValue;

            if (!hasZTopValue && !hasZBottomValue)
            {
                return(true);
            }

            RoundedDouble zTop = hasZTopValue
                                     ? (RoundedDouble)gridConfiguration.ZTop.Value
                                     : RoundedDouble.NaN;

            RoundedDouble zBottom = hasZBottomValue
                                        ? (RoundedDouble)gridConfiguration.ZBottom.Value
                                        : RoundedDouble.NaN;

            try
            {
                grid.ZTop    = zTop;
                grid.ZBottom = zBottom;
            }
            catch (ArgumentException e)
            {
                Log.LogCalculationConversionError(string.Format(Resources.MacroStabilityInwardsCalculationConfigurationImporter_TrySetGridZTopZBottom_Combination_of_ZTop_0_and_ZBottom_1_invalid_Reason_2,
                                                                zTop.ToPrecision(grid.ZTop.NumberOfDecimalPlaces),
                                                                zBottom.ToPrecision(grid.ZBottom.NumberOfDecimalPlaces),
                                                                e.Message),
                                                  calculationName);

                return(false);
            }

            return(true);
        }
Beispiel #5
0
        /// <summary>
        /// Tries to assign the tangent line Z top and tangent line Z bottom parameters to the <paramref name="calculation"/>.
        /// </summary>
        /// <param name="calculationConfiguration">The calculation read from the imported file.</param>
        /// <param name="calculation">The calculation to configure.</param>
        /// <returns><c>true</c> if no tangent line z top and tangent line z bottom was given, or when
        /// tangent line z top and tangent line z bottom are set to the <paramref name="calculation"/>,
        /// <c>false</c> otherwise.</returns>
        private bool TrySetTangentLineZTopBottom(MacroStabilityInwardsCalculationConfiguration calculationConfiguration,
                                                 MacroStabilityInwardsCalculationScenario calculation)
        {
            bool hasTangentLineZTop    = calculationConfiguration.TangentLineZTop.HasValue;
            bool hasTangentLineZBottom = calculationConfiguration.TangentLineZBottom.HasValue;

            if (!hasTangentLineZTop && !hasTangentLineZBottom)
            {
                return(true);
            }

            RoundedDouble tangentLineZTop = hasTangentLineZTop
                                                ? (RoundedDouble)calculationConfiguration.TangentLineZTop.Value
                                                : RoundedDouble.NaN;
            RoundedDouble tangentLineZBottom = hasTangentLineZBottom
                                                   ? (RoundedDouble)calculationConfiguration.TangentLineZBottom.Value
                                                   : RoundedDouble.NaN;

            MacroStabilityInwardsInput input = calculation.InputParameters;

            try
            {
                input.TangentLineZTop    = tangentLineZTop;
                input.TangentLineZBottom = tangentLineZBottom;
            }
            catch (ArgumentException e)
            {
                Log.LogCalculationConversionError(string.Format(Resources.MacroStabilityInwardsCalculationConfigurationImporter_TrySetTangentLineZTopBottom_Combination_of_TangentLineZTop_0_and_TangentLineZBottom_1_invalid_Reason_2,
                                                                tangentLineZTop.ToPrecision(input.TangentLineZTop.NumberOfDecimalPlaces),
                                                                tangentLineZBottom.ToPrecision(input.TangentLineZTop.NumberOfDecimalPlaces),
                                                                e.Message),
                                                  calculation.Name);

                return(false);
            }

            return(true);
        }