Exemple #1
0
                /// <summary>
                /// Tests that the
                /// <see cref="PrincipalProjections.RegressSupplementaryVariables"/>
                /// method fails when supplementaryVariables is null.
                public static void SupplementaryVariablesIsNull(
                    TestablePrincipalProjections testablePrincipalProjections)
                {
                    var principalProjections =
                        testablePrincipalProjections.PrincipalProjections;

                    string parameterName = "supplementaryVariables";

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        principalProjections.RegressSupplementaryVariables(
                            (DoubleMatrix)null);
                    },
                        expectedType: typeof(ArgumentNullException),
                        expectedPartialMessage:
                        ArgumentExceptionAssert.NullPartialMessage,
                        expectedParameterName: parameterName);

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        principalProjections.RegressSupplementaryVariables(
                            (ReadOnlyDoubleMatrix)null);
                    },
                        expectedType: typeof(ArgumentNullException),
                        expectedPartialMessage:
                        ArgumentExceptionAssert.NullPartialMessage,
                        expectedParameterName: parameterName);
                }
                /// <summary>
                /// Provides methods to test that the
                /// <see cref="NumericalBlock.
                /// GetNumericalBlocks(DoubleMatrix, DoubleMatrix)"/>
                /// method fails when numerical and target data
                /// have different lengths.
                public static void NumericalAndTargetDataHaveDifferentLengths()
                {
                    var numericalData = DoubleMatrix.Dense(5, 1,
                                                           new double[5] {
                        -1, -1, -1, 1, 1
                    });
                    var targetData = DoubleMatrix.Dense(4, 1,
                                                        new double[4] {
                        20, 10, 10, 10
                    });

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var blocks = NumericalBlock.GetNumericalBlocks(
                            numericalData,
                            targetData);
                    },
                        expectedType: typeof(ArgumentException),
                        expectedPartialMessage: string.Format(
                            ImplementationServices.GetResourceString(
                                "STR_EXCEPT_PAR_MUST_HAVE_SAME_COUNT"),
                            nameof(numericalData)),
                        expectedParameterName: "targetData");
                }
Exemple #3
0
                /// <summary>
                /// Tests that the
                /// <see cref="PrincipalProjections.RegressSupplementaryVariables"/>
                /// method fails when supplementaryVariables has not
                /// the expected number of rows.
                public static void SupplementaryVariablesHasWrongNumberOfRows(
                    TestablePrincipalProjections testablePrincipalProjections)
                {
                    var principalProjections =
                        testablePrincipalProjections.PrincipalProjections;

                    var STR_EXCEPT_GDA_ROWS_NOT_EQUAL_TO_ACTIVE_POINTS =
                        ImplementationServices.GetResourceString(
                            "STR_EXCEPT_GDA_ROWS_NOT_EQUAL_TO_ACTIVE_POINTS");

                    string parameterName = "supplementaryVariables";

                    DoubleMatrix supplementaryVariables =
                        DoubleMatrix.Dense(
                            principalProjections.ActiveCloud.Coordinates.NumberOfRows + 1,
                            2);

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        principalProjections.RegressSupplementaryVariables(
                            supplementaryVariables);
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage:
                        STR_EXCEPT_GDA_ROWS_NOT_EQUAL_TO_ACTIVE_POINTS,
                        expectedParameterName: parameterName);
                }
                /// <summary>
                /// Tests that samplers
                /// in <see cref="RandomNumberGenerator"/>
                /// filling an array with a sample fail
                /// when parameter destinationIndex is negative.
                /// </summary>
                /// <typeparam name="TSample">The type of a sample point.</typeparam>
                /// <typeparam name="TParameters">
                /// The type of the distribution parameters.</typeparam>
                /// <param name="sampleArrayFunc">
                /// A method returning a sample from a
                /// statistical distribution having the specified
                /// parameters.</param>
                /// <param name="distributionParameters">The parameters of the distribution
                /// from which the sample is drawn.</param>
                public static void DestinationIndexIsNegative <TSample, TParameters>(
                    SampleArrayFunc <TSample, TParameters> sampleArrayFunc,
                    TParameters[] distributionParameters)
                {
                    string STR_EXCEPT_PAR_MUST_BE_NON_NEGATIVE =
                        (string)Reflector.ExecuteStaticMember(
                            typeof(ImplementationServices),
                            "GetResourceString",
                            new string[] { "STR_EXCEPT_PAR_MUST_BE_NON_NEGATIVE" });

                    string parameterName = "destinationIndex";

                    // distribution.Sample(sampleSize, destinationArray, destinationIndex)
                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        sampleArrayFunc(
                            sampleSize: 1,
                            destinationArray: new TSample[1],
                            destinationIndex: -1,
                            parameters: distributionParameters);
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_PAR_MUST_BE_NON_NEGATIVE,
                        expectedParameterName: parameterName);
                }
Exemple #5
0
                /// <summary>
                /// Tests that the
                /// <see cref="PrincipalProjections.LocateSupplementaryPoints"/>
                /// method fails when activeCoordinates has not
                /// the expected number of columns.
                public static void ActiveCoordinatesHasWrongNumberOfColumns(
                    TestablePrincipalProjections testablePrincipalProjections)
                {
                    var principalProjections =
                        testablePrincipalProjections.PrincipalProjections;

                    var STR_EXCEPT_GDA_COLUMNS_NOT_EQUAL_TO_ACTIVE_VARIABLES =
                        ImplementationServices.GetResourceString(
                            "STR_EXCEPT_GDA_COLUMNS_NOT_EQUAL_TO_ACTIVE_VARIABLES");

                    string parameterName = "activeCoordinates";

                    DoubleMatrix activeCoordinates =
                        DoubleMatrix.Dense(
                            2,
                            principalProjections.ActiveCloud.Coordinates.NumberOfColumns + 1);

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        principalProjections.LocateSupplementaryPoints(
                            activeCoordinates);
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage:
                        STR_EXCEPT_GDA_COLUMNS_NOT_EQUAL_TO_ACTIVE_VARIABLES,
                        expectedParameterName: parameterName);
                }
                /// <summary>
                /// Tests that samplers
                /// in <see cref="RandomNumberGenerator"/>
                /// filling an array with a sample fail
                /// when parameter sampleSize is too big to
                /// fit in the destination array.
                /// </summary>
                /// <typeparam name="TSample">The type of a sample point.</typeparam>
                /// <typeparam name="TParameters">
                /// The type of the distribution parameters.</typeparam>
                /// <param name="sampleArrayFunc">
                /// A method returning a sample from a
                /// statistical distribution having the specified
                /// parameters.</param>
                /// <param name="distributionParameters">The parameters of the distribution
                /// from which the sample is drawn.</param>
                public static void SampleSizeIsTooBig <TSample, TParameters>(
                    SampleArrayFunc <TSample, TParameters> sampleArrayFunc,
                    TParameters[] distributionParameters)
                {
                    string STR_EXCEPT_PDF_SAMPLESIZE_ARRAYLENGTH_MISMATCH =
                        String.Format(
                            (string)Reflector.ExecuteStaticMember(
                                typeof(ImplementationServices),
                                "GetResourceString",
                                new string[] { "STR_EXCEPT_PDF_SAMPLESIZE_ARRAYLENGTH_MISMATCH" }),
                            "sampleSize",
                            "destinationArray",
                            "destinationIndex");


                    string parameterName = "sampleSize";

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        sampleArrayFunc(
                            sampleSize: 2,
                            destinationArray: new TSample[1],
                            destinationIndex: 0,
                            parameters: distributionParameters);
                    },
                        expectedType: typeof(ArgumentException),
                        expectedPartialMessage: STR_EXCEPT_PDF_SAMPLESIZE_ARRAYLENGTH_MISMATCH,
                        expectedParameterName: parameterName);
                }
Exemple #7
0
                /// <summary>
                /// Tests that the
                /// <see cref="ProbabilityDistribution.
                /// Sample(int, double[], int)"/>
                /// method fails when parameter sampleSize is too big to
                /// fit in the destination array.
                /// </summary>
                /// <param name="testableDistribution">
                /// The testable probability distribution providing the instance
                /// on which to invoke the methods to test and their expected
                /// behaviors.
                /// </param>
                public static void SampleSizeIsTooBig(
                    TestableProbabilityDistribution testableDistribution)
                {
                    string STR_EXCEPT_PDF_SAMPLESIZE_ARRAYLENGTH_MISMATCH =
                        String.Format(
                            (string)Reflector.ExecuteStaticMember(
                                typeof(ImplementationServices),
                                "GetResourceString",
                                new string[] { "STR_EXCEPT_PDF_SAMPLESIZE_ARRAYLENGTH_MISMATCH" }),
                            "sampleSize",
                            "destinationArray",
                            "destinationIndex");


                    string parameterName = "sampleSize";

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        testableDistribution.Distribution.Sample(
                            sampleSize: 2,
                            destinationArray: new double[1],
                            destinationIndex: 0);
                    },
                        expectedType: typeof(ArgumentException),
                        expectedPartialMessage: STR_EXCEPT_PDF_SAMPLESIZE_ARRAYLENGTH_MISMATCH,
                        expectedParameterName: parameterName);
                }
Exemple #8
0
                /// <summary>
                /// Tests that the
                /// <see cref="O:Novacta.Analytics.ProbabilityDistribution.
                /// Sample"/>
                /// method fails when parameter sampleSize is not positive.
                /// </summary>
                /// <param name="testableDistribution">
                /// The testable probability distribution providing the instance
                /// on which to invoke the methods to test and their expected
                /// behaviors.
                /// </param>
                public static void SampleSizeIsNotPositive(
                    TestableProbabilityDistribution testableDistribution)
                {
                    string STR_EXCEPT_PAR_MUST_BE_POSITIVE =
                        (string)Reflector.ExecuteStaticMember(
                            typeof(ImplementationServices),
                            "GetResourceString",
                            new string[] { "STR_EXCEPT_PAR_MUST_BE_POSITIVE" });

                    string parameterName = "sampleSize";

                    // distribution.Sample(sampleSize)
                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var values = testableDistribution.Distribution.Sample(
                            sampleSize: 0);
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_PAR_MUST_BE_POSITIVE,
                        expectedParameterName: parameterName);

                    // distribution.Sample(sampleSize, destinationArray, destinationIndex)
                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        testableDistribution.Distribution.Sample(
                            sampleSize: 0,
                            destinationArray: new double[1],
                            destinationIndex: 0);
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_PAR_MUST_BE_POSITIVE,
                        expectedParameterName: parameterName);
                }
Exemple #9
0
                /// <summary>
                /// Provides methods to test that the
                /// <see cref="O:Novacta.Analytics.ProbabilityDistribution.
                /// InverseCdf"/>
                /// method fails when parameter arguments is <b>null</b>.
                /// </summary>
                /// <param name="testableDistribution">
                /// The testable probability distribution providing the instance
                /// on which to invoke the methods to test and their expected
                /// behaviors.
                /// </param>
                public static void ArgumentsIsNull(
                    TestableProbabilityDistribution testableDistribution)
                {
                    string parameterName = "arguments";

                    // DoubleMatrix
                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var values = testableDistribution.Distribution.InverseCdf(
                            arguments: (DoubleMatrix)null);
                    },
                        expectedType: typeof(ArgumentNullException),
                        expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                        expectedParameterName: parameterName);

                    // ReadOnlyDoubleMatrix
                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var values = testableDistribution.Distribution.InverseCdf(
                            arguments: (ReadOnlyDoubleMatrix)null);
                    },
                        expectedType: typeof(ArgumentNullException),
                        expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                        expectedParameterName: parameterName);
                }
Exemple #10
0
                /// <summary>
                /// Tests that the
                /// <see cref="ProbabilityDistribution.
                /// Sample(int, double[], int)"/>
                /// method fails when parameter destinationArray is <b>null</b>.
                /// </summary>
                /// <param name="testableDistribution">
                /// The testable probability distribution providing the instance
                /// on which to invoke the methods to test and their expected
                /// behaviors.
                /// </param>
                public static void DestinationArrayIsNull(
                    TestableProbabilityDistribution testableDistribution)
                {
                    string parameterName = "destinationArray";

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        testableDistribution.Distribution.Sample(
                            sampleSize: 1,
                            destinationArray: null,
                            destinationIndex: 0);
                    },
                        expectedType: typeof(ArgumentNullException),
                        expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                        expectedParameterName: parameterName);
                }
Exemple #11
0
            /// <summary>
            /// Tests the operation
            /// when its operand is set through a value represented by a <b>null</b> instance.
            /// </summary>
            public static void MatrixIsNull()
            {
                ArgumentExceptionAssert.Throw(
                    () =>
                {
                    SpectralDecomposition.GetEigenvalues(
                        matrix: (DoubleMatrix)null,
                        lowerTriangularPart: true);
                },
                    expectedType: typeof(ArgumentNullException),
                    expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                    expectedParameterName: "matrix");

                ArgumentExceptionAssert.Throw(
                    () =>
                {
                    SpectralDecomposition.GetEigenvalues(
                        matrix: (ReadOnlyDoubleMatrix)null,
                        lowerTriangularPart: true);
                },
                    expectedType: typeof(ArgumentNullException),
                    expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                    expectedParameterName: "matrix");

                ArgumentExceptionAssert.Throw(
                    () =>
                {
                    SpectralDecomposition.GetEigenvalues(
                        matrix: (ComplexMatrix)null,
                        lowerTriangularPart: true);
                },
                    expectedType: typeof(ArgumentNullException),
                    expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                    expectedParameterName: "matrix");

                ArgumentExceptionAssert.Throw(
                    () =>
                {
                    SpectralDecomposition.GetEigenvalues(
                        matrix: (ReadOnlyComplexMatrix)null,
                        lowerTriangularPart: true);
                },
                    expectedType: typeof(ArgumentNullException),
                    expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                    expectedParameterName: "matrix");
            }
                /// <summary>
                /// Provides methods to test that the
                /// <see cref="NumericalBlock.
                /// GetNumericalBlocks(DoubleMatrix, DoubleMatrix)"/>
                /// method fails when the numerical data is <b>null</b>.
                public static void NumericalDataIsNull()
                {
                    DoubleMatrix numericalData = null;
                    var          targetData    = DoubleMatrix.Dense(5, 1,
                                                                    new double[5] {
                        10, 20, 10, 10, 10
                    });

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var blocks = NumericalBlock.GetNumericalBlocks(
                            numericalData,
                            targetData);
                    },
                        expectedType: typeof(ArgumentNullException),
                        expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                        expectedParameterName: "numericalData");
                }
Exemple #13
0
                /// <summary>
                /// Provides methods to test that the
                /// <see cref="NumericalBin.
                /// GetNumericalBins(DoubleMatrix, DoubleMatrix)"/>
                /// method fails when the target data is <b>null</b>.
                public static void TargetDataIsNull()
                {
                    var numericalData = DoubleMatrix.Dense(5, 1,
                                                           new double[5] {
                        -1, -1, -1, 1, 1
                    });
                    DoubleMatrix targetData = null;

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var bins = NumericalBin.GetNumericalBins(
                            numericalData,
                            targetData);
                    },
                        expectedType: typeof(ArgumentNullException),
                        expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                        expectedParameterName: "targetData");
                }
                /// <summary>
                /// Tests that samplers
                /// in <see cref="RandomNumberGenerator"/>
                /// filling an array with a sample fail
                /// when parameter destinationArray is <b>null</b>.
                /// </summary>
                /// <typeparam name="TSample">The type of a sample point.</typeparam>
                /// <typeparam name="TParameters">
                /// The type of the distribution parameters.</typeparam>
                /// <param name="sampleArrayFunc">
                /// A method returning a sample from a
                /// statistical distribution having the specified
                /// parameters.</param>
                /// <param name="distributionParameters">The parameters of the distribution
                /// from which the sample is drawn.</param>
                public static void DestinationArrayIsNull <TSample, TParameters>(
                    SampleArrayFunc <TSample, TParameters> sampleArrayFunc,
                    TParameters[] distributionParameters)
                {
                    string parameterName = "destinationArray";

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        sampleArrayFunc(
                            sampleSize: 1,
                            destinationArray: null,
                            destinationIndex: 0,
                            parameters: distributionParameters);
                    },
                        expectedType: typeof(ArgumentNullException),
                        expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                        expectedParameterName: parameterName);
                }
Exemple #15
0
                /// <summary>
                /// Tests getting property
                /// <see cref="O:IReadOnlyTabularCollection{TValue, TCollection}.this"/>
                /// when a row index is out of range.
                /// </summary>
                /// <typeparam name="TValue">The type of the items in the collection.</typeparam>
                /// <typeparam name="TCollection">The type of the collection.</typeparam>
                /// <param name="source">The source instance on which to invoke the property getter.</param>
                public static void AnyRowIndexIsOutOrRange <TValue, TCollection>(
                    IReadOnlyTabularCollection <TValue, TCollection> source)
                    where TCollection : IReadOnlyTabularCollection <TValue, TCollection>
                {
                    Assert.IsNotNull(source);

                    string STR_EXCEPT_TAB_INDEX_EXCEEDS_DIMS =
                        (string)Reflector.ExecuteStaticMember(
                            typeof(ImplementationServices),
                            "GetResourceString",
                            new string[] { "STR_EXCEPT_TAB_INDEX_EXCEEDS_DIMS" });

                    string parameterName = null;

                    #region Int32

                    parameterName = "rowIndex";

                    // Int32

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source[-1, 0];
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_TAB_INDEX_EXCEEDS_DIMS,
                        expectedParameterName: parameterName);

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source[source.NumberOfRows, 0];
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_TAB_INDEX_EXCEEDS_DIMS,
                        expectedParameterName: parameterName);

                    // IndexCollection

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source[-1, IndexCollection.Range(0, source.NumberOfColumns - 1)];
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_TAB_INDEX_EXCEEDS_DIMS,
                        expectedParameterName: parameterName);

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source[source.NumberOfRows, IndexCollection.Range(0, source.NumberOfColumns - 1)];
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_TAB_INDEX_EXCEEDS_DIMS,
                        expectedParameterName: parameterName);

                    // String

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source[-1, ":"];
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_TAB_INDEX_EXCEEDS_DIMS,
                        expectedParameterName: parameterName);

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source[source.NumberOfRows, ":"];
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_TAB_INDEX_EXCEEDS_DIMS,
                        expectedParameterName: parameterName);

                    #endregion

                    #region IndexCollection

                    parameterName = "rowIndexes";

                    // Int32

                    //          IndexCollection instances cannot contain negative elements

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source[IndexCollection.Range(0, source.NumberOfRows), 0];
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_TAB_INDEX_EXCEEDS_DIMS,
                        expectedParameterName: parameterName);

                    // IndexCollection

                    //          IndexCollection instances cannot contain negative elements

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source[IndexCollection.Range(0, source.NumberOfRows), IndexCollection.Range(0, source.NumberOfColumns - 1)];
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_TAB_INDEX_EXCEEDS_DIMS,
                        expectedParameterName: parameterName);

                    // String

                    //          IndexCollection instances cannot contain negative elements

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source[IndexCollection.Range(0, source.NumberOfRows), ":"];
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_TAB_INDEX_EXCEEDS_DIMS,
                        expectedParameterName: parameterName);

                    #endregion

                    #region String

                    parameterName = "rowIndexes";

                    var STR_EXCEPT_TAB_UNSUPPORTED_SUBREF_SYNTAX =
                        (string)Reflector.ExecuteStaticMember(
                            typeof(ImplementationServices),
                            "GetResourceString",
                            new string[] { "STR_EXCEPT_TAB_UNSUPPORTED_SUBREF_SYNTAX" });

                    // Int32

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source["", 0];
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_TAB_UNSUPPORTED_SUBREF_SYNTAX,
                        expectedParameterName: parameterName);

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source["end", 0];
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_TAB_UNSUPPORTED_SUBREF_SYNTAX,
                        expectedParameterName: parameterName);

                    // IndexCollection

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source["", IndexCollection.Range(0, source.NumberOfColumns - 1)];
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_TAB_UNSUPPORTED_SUBREF_SYNTAX,
                        expectedParameterName: parameterName);

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source["end", IndexCollection.Range(0, source.NumberOfColumns - 1)];
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_TAB_UNSUPPORTED_SUBREF_SYNTAX,
                        expectedParameterName: parameterName);

                    // String

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source["", ":"];
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_TAB_UNSUPPORTED_SUBREF_SYNTAX,
                        expectedParameterName: parameterName);

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source["end", ":"];
                    },
                        expectedType: typeof(ArgumentOutOfRangeException),
                        expectedPartialMessage: STR_EXCEPT_TAB_UNSUPPORTED_SUBREF_SYNTAX,
                        expectedParameterName: parameterName);

                    #endregion
                }
Exemple #16
0
                /// <summary>
                /// Tests getting property
                /// <see cref="O:IReadOnlyTabularCollection{TValue, TCollection}.this"/>
                /// when column indexes are represented by a <b>null</b> instance.
                /// </summary>
                /// <typeparam name="TValue">The type of the items in the collection.</typeparam>
                /// <typeparam name="TCollection">The type of the collection.</typeparam>
                /// <param name="source">The source instance on which to invoke the property getter.</param>
                public static void ColumnIndexesIsNull <TValue, TCollection>(
                    IReadOnlyTabularCollection <TValue, TCollection> source)
                    where TCollection : IReadOnlyTabularCollection <TValue, TCollection>
                {
                    Assert.IsNotNull(source);

                    string parameterName = null;

                    #region IndexCollection

                    parameterName = "columnIndexes";

                    // Int32

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source[0, (IndexCollection)null];
                    },
                        expectedType: typeof(ArgumentNullException),
                        expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                        expectedParameterName: parameterName);

                    // IndexCollection

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source[IndexCollection.Range(0, source.NumberOfColumns - 1), (IndexCollection)null];
                    },
                        expectedType: typeof(ArgumentNullException),
                        expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                        expectedParameterName: parameterName);

                    // String

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source[":", (IndexCollection)null];
                    },
                        expectedType: typeof(ArgumentNullException),
                        expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                        expectedParameterName: parameterName);

                    #endregion

                    #region String

                    parameterName = "columnIndexes";

                    // Int32

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source[0, (string)null];
                    },
                        expectedType: typeof(ArgumentNullException),
                        expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                        expectedParameterName: parameterName);

                    // IndexCollection

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source[IndexCollection.Range(0, source.NumberOfColumns - 1), (string)null];
                    },
                        expectedType: typeof(ArgumentNullException),
                        expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                        expectedParameterName: parameterName);

                    // String

                    ArgumentExceptionAssert.Throw(
                        () =>
                    {
                        var sub =
                            source[":", (string)null];
                    },
                        expectedType: typeof(ArgumentNullException),
                        expectedPartialMessage: ArgumentExceptionAssert.NullPartialMessage,
                        expectedParameterName: parameterName);

                    #endregion
                }