コード例 #1
0
ファイル: EmptyConstraint.cs プロジェクト: idavis/Ensurance
 /// <summary>
 /// Write the constraint description to a MessageWriter
 /// </summary>
 /// <param name="writer">The writer on which the description is displayed</param>
 /// <exception cref="ArgumentNullException">if the message writer is null.</exception>
 public override void WriteDescriptionTo( MessageWriter writer )
 {
     if ( writer == null )
     {
         throw new ArgumentNullException( "writer" );
     }
     writer.Write( Resources.Empty );
 }
コード例 #2
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 );
                }
            }
        }