예제 #1
0
 /// <summary>
 /// Displays the differences.
 /// </summary>
 /// <param name="writer">The writer.</param>
 /// <param name="expected">The expected.</param>
 /// <param name="actual">The actual.</param>
 /// <param name="depth">The depth.</param>
 private void DisplayDifferences( MessageWriter writer, object expected, object actual, int depth )
 {
     if ( expected is string && actual is string )
     {
         DisplayStringDifferences( writer, (string) expected, (string) actual );
     }
     else if ( expected is ICollection && actual is ICollection )
     {
         DisplayCollectionDifferences( writer, expected as ICollection, actual as ICollection, depth );
     }
     else if ( expected is Stream && actual is Stream )
     {
         DisplayStreamDifferences( writer, expected as Stream, actual as Stream, depth );
     }
     else if ( Tolerance != null )
     {
         writer.DisplayDifferences( expected, actual, Tolerance );
     }
     else
     {
         writer.DisplayDifferences( expected, actual );
     }
 }
예제 #2
0
 /// <summary>
 /// Write the failure message to the MessageWriter provided as an
 /// argument. The default implementation simply passes the constraint
 /// and the actual value to the writer, which then displays the
 /// constraint description and the value.
 /// 
 /// Constraints that need to provide additional details, such as where
 /// the error occured can override this.
 /// </summary>
 /// <exception cref="ArgumentNullException">if the message writer is null.</exception>
 /// <param name="writer">The MessageWriter on which to display the message</param>
 public virtual void WriteMessageTo( MessageWriter writer )
 {
     if ( writer == null )
     {
         throw new ArgumentNullException( "writer" );
     }
     writer.DisplayDifferences( this );
 }