GetArrayIndicesAsString() public static méthode

Return the a string representation for a set of indices into an array
public static GetArrayIndicesAsString ( int indices ) : string
indices int Array of indices for which a string is needed
Résultat string
Exemple #1
0
        /// <summary>
        /// Displays a single line showing the point in the expected and actual
        /// arrays at which the comparison failed. If the arrays have different
        /// structures or dimensions, both values are shown.
        /// </summary>
        /// <param name="writer">The MessageWriter on which to display</param>
        /// <param name="expected">The expected array</param>
        /// <param name="actual">The actual array</param>
        /// <param name="failurePoint">Index of the failure point in the underlying collections</param>
        /// <param name="indent">The indentation level for the message line</param>
        private void DisplayFailurePoint(MessageWriter writer, IEnumerable expected, IEnumerable actual, NUnitEqualityComparer.FailurePoint failurePoint, int indent)
        {
            Array expectedArray = expected as Array;
            Array actualArray   = actual as Array;

            int expectedRank = expectedArray != null ? expectedArray.Rank : 1;
            int actualRank   = actualArray != null ? actualArray.Rank : 1;

            bool useOneIndex = expectedRank == actualRank;

            if (expectedArray != null && actualArray != null)
            {
                for (int r = 1; r < expectedRank && useOneIndex; r++)
                {
                    if (expectedArray.GetLength(r) != actualArray.GetLength(r))
                    {
                        useOneIndex = false;
                    }
                }
            }

            int[] expectedIndices = MsgUtils.GetArrayIndicesFromCollectionIndex(expected, failurePoint.Position);
            if (useOneIndex)
            {
                writer.WriteMessageLine(indent, ValuesDiffer_1, MsgUtils.GetArrayIndicesAsString(expectedIndices));
            }
            else
            {
                int[] actualIndices = MsgUtils.GetArrayIndicesFromCollectionIndex(actual, failurePoint.Position);
                writer.WriteMessageLine(indent, ValuesDiffer_2,
                                        MsgUtils.GetArrayIndicesAsString(expectedIndices), MsgUtils.GetArrayIndicesAsString(actualIndices));
            }
        }
Exemple #2
0
        private void DisplayFailurePoint(MessageWriter writer, IEnumerable expected, IEnumerable actual, NUnitEqualityComparer.FailurePoint failurePoint, int indent)
        {
            Array array  = expected as Array;
            Array array2 = actual as Array;
            int   num    = array?.Rank ?? 1;
            int   num2   = array2?.Rank ?? 1;
            bool  flag   = num == num2;

            if (array != null && array2 != null)
            {
                for (int i = 1; i < num; i++)
                {
                    if (!flag)
                    {
                        break;
                    }
                    if (array.GetLength(i) != array2.GetLength(i))
                    {
                        flag = false;
                    }
                }
            }
            int[] arrayIndicesFromCollectionIndex = MsgUtils.GetArrayIndicesFromCollectionIndex(expected, failurePoint.Position);
            if (flag)
            {
                writer.WriteMessageLine(indent, ValuesDiffer_1, MsgUtils.GetArrayIndicesAsString(arrayIndicesFromCollectionIndex));
                return;
            }
            int[] arrayIndicesFromCollectionIndex2 = MsgUtils.GetArrayIndicesFromCollectionIndex(actual, failurePoint.Position);
            writer.WriteMessageLine(indent, ValuesDiffer_2, MsgUtils.GetArrayIndicesAsString(arrayIndicesFromCollectionIndex), MsgUtils.GetArrayIndicesAsString(arrayIndicesFromCollectionIndex2));
        }