Exemplo n.º 1
0
        public void ConvertFrom_InvalidMacroStabilityInwardsTangentLineDeterminationType_ThrowsInvalidEnumArgumentException()
        {
            // Setup
            const MacroStabilityInwardsTangentLineDeterminationType invalidValue = (MacroStabilityInwardsTangentLineDeterminationType)9999;
            var converter = new ConfigurationTangentLineDeterminationTypeConverter();

            // Call
            TestDelegate call = () => converter.ConvertFrom(invalidValue);

            // Assert
            string expectedMessage = $"The value of argument 'value' ({invalidValue}) is invalid for Enum type '{nameof(MacroStabilityInwardsTangentLineDeterminationType)}'.";
            string parameterName   = TestHelper.AssertThrowsArgumentExceptionAndTestMessage <InvalidEnumArgumentException>(call, expectedMessage).ParamName;

            Assert.AreEqual("value", parameterName);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Create tangent lines based on the provided amount <paramref name="tangentLineNumber"/> and
        /// range between <paramref name="tangentLineBottom"/> and <paramref name="tangentLineTop"/>
        /// within the boundaries of the <paramref name="surfaceLine"/>.
        /// </summary>
        /// <param name="gridDeterminationType">The grid determination type.</param>
        /// <param name="tangentLineDeterminationType">The tangent line determination type.</param>
        /// <param name="tangentLineBottom">The bottom boundary for the tangent lines.</param>
        /// <param name="tangentLineTop">The top boundary for the tangent lines.</param>
        /// <param name="tangentLineNumber">The amount of tangent lines to display.</param>
        /// <param name="surfaceLine">The surface line that determines the horizontal boundaries
        /// of the tangent lines.</param>
        /// <returns>A collection of collections of points in 2D space or an empty collection when:
        /// <list type="bullet">
        /// <item><paramref name="gridDeterminationType"/> is <see cref="MacroStabilityInwardsGridDeterminationType.Automatic"/>;</item>
        /// <item><paramref name="tangentLineDeterminationType"/> is <see cref="MacroStabilityInwardsTangentLineDeterminationType.LayerSeparated"/>;</item>
        /// <item><paramref name="surfaceLine"/> is <c>null</c>;</item>
        /// <item><paramref name="tangentLineBottom"/> is <see cref="double.NaN"/> or infinity;</item>
        /// <item><paramref name="tangentLineTop"/> is <see cref="double.NaN"/> or infinity.</item>
        /// </list>
        /// </returns>
        public static IEnumerable <IEnumerable <Point2D> > CreateTangentLines(MacroStabilityInwardsGridDeterminationType gridDeterminationType,
                                                                              MacroStabilityInwardsTangentLineDeterminationType tangentLineDeterminationType,
                                                                              RoundedDouble tangentLineBottom,
                                                                              RoundedDouble tangentLineTop,
                                                                              int tangentLineNumber,
                                                                              MacroStabilityInwardsSurfaceLine surfaceLine)
        {
            if (gridDeterminationType == MacroStabilityInwardsGridDeterminationType.Automatic ||
                tangentLineDeterminationType == MacroStabilityInwardsTangentLineDeterminationType.LayerSeparated ||
                double.IsNaN(tangentLineBottom) ||
                double.IsInfinity(tangentLineBottom) ||
                double.IsNaN(tangentLineTop) ||
                double.IsInfinity(tangentLineTop))
            {
                return(Enumerable.Empty <IEnumerable <Point2D> >());
            }

            return(CreateTangentLines(GetInterPolatedVerticalPositions(tangentLineTop, tangentLineBottom, tangentLineNumber),
                                      surfaceLine));
        }