コード例 #1
0
ファイル: EqualConstraint.cs プロジェクト: idavis/Ensurance
        /// <summary>
        /// Display the failure information for two collections that did not
        /// match.
        /// </summary>
        /// <param name="writer">The MessageWriter on which to display</param>
        /// <param name="expected">The expected collection.</param>
        /// <param name="actual">The actual collection</param>
        /// <param name="depth">The depth of this failure in a set of nested collections</param>
        private void DisplayCollectionDifferences( MessageWriter writer, ICollection expected, ICollection actual, int depth )
        {
            int failurePoint = _failurePoints.Count > depth ? (int) _failurePoints[depth] : -1;

            DisplayCollectionTypesAndSizes( writer, expected, actual, depth );

            if ( failurePoint >= 0 )
            {
                DisplayFailurePoint( writer, expected, actual, failurePoint, depth );
                if ( failurePoint < expected.Count && failurePoint < actual.Count )
                {
                    DisplayDifferences(
                        writer,
                        GetValueFromCollection( expected, failurePoint ),
                        GetValueFromCollection( actual, failurePoint ),
                        ++depth );
                }
                else if ( expected.Count < actual.Count )
                {
                    writer.Write( string.Format( "  {0}:    ", Resources.Extra ) );
                    writer.WriteCollectionElements( actual, failurePoint, 3 );
                }
                else
                {
                    writer.Write(string.Format( "  {0}:  ", Resources.Missing ));
                    writer.WriteCollectionElements( expected, failurePoint, 3 );
                }
            }
        }