NUnit.Framework.AssertionFailureMessage.AddLine(string, params object[])

Here are the examples of the csharp api class NUnit.Framework.AssertionFailureMessage.AddLine(string, params object[]) taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

10 Examples 7

1. Example

Project: 32feet
Source File: AssertionFailureMessage.cs
View license
protected void BuildStringLengthReport( string sExpected, string sActual )
		{
			if( sExpected.Length != sActual.Length )
				AddLine( diffStringLengthsFmt, sExpected.Length, sActual.Length );
			else
				AddLine( sameStringLengthsFmt, sExpected.Length );
		}

2. Example

Project: 32feet
Source File: AssertionFailureMessage.cs
View license
public void DisplayPositionMarker( int iPosition )
		{
			AddLine( "\t{0}^", new String( '-', expectedPrefix.Length + iPosition + 3 ) );
		}

3. Example

Project: 32feet
Source File: AssertionFailureMessage.cs
View license
protected void BuildStringLengthReport( string sExpected, string sActual )
		{
			if( sExpected.Length != sActual.Length )
				AddLine( diffStringLengthsFmt, sExpected.Length, sActual.Length );
			else
				AddLine( sameStringLengthsFmt, sExpected.Length );
		}

4. Example

Project: 32feet
Source File: AssertionFailureMessage.cs
View license
public void DisplayPositionMarker( int iPosition )
		{
			AddLine( "\t{0}^", new String( '-', expectedPrefix.Length + iPosition + 3 ) );
		}

5. Example

Project: 32feet
Source File: AssertionFailureMessage.cs
View license
public void DisplayListElements( string label, IList list, int index, int max )
		{
			AddLine( "{0}<", label );

			if ( list == null )
				Write( "null" );
			else if ( list.Count == 0 )
				Write( "empty" );
			else
			{
				for( int i = 0; i < max && index < list.Count; i++ )
				{
					Write( FormatObjectForDisplay( list[index++] ) );
				
					if ( index < list.Count )
						Write( "," );
				}

				if ( index < list.Count )
					Write( "..." );
			}

			Write( ">" );
		}

6. Example

Project: 32feet
Source File: AssertionFailureMessage.cs
View license
public void DisplayListElements( string label, IList list, int index, int max )
		{
			AddLine( "{0}<", label );

			if ( list == null )
				Write( "null" );
			else if ( list.Count == 0 )
				Write( "empty" );
			else
			{
				for( int i = 0; i < max && index < list.Count; i++ )
				{
					Write( FormatObjectForDisplay( list[index++] ) );
				
					if ( index < list.Count )
						Write( "," );
				}

				if ( index < list.Count )
					Write( "..." );
			}

			Write( ">" );
		}

7. Example

Project: 32feet
Source File: AssertionFailureMessage.cs
View license
public void DisplayArrayDifferences( Array expected, Array actual, int index )
		{
			if( expected.Length != actual.Length )
				AddLine( diffArrayLengthsFmt, expected.Length, actual.Length );
			else
				AddLine( sameArrayLengthsFmt, expected.Length );
			
			AddLine( arraysDifferAtIndexFmt, index );
				
			if ( index < expected.Length && index < actual.Length )
				DisplayDifferences( expected.GetValue( index ), actual.GetValue( index ), false );
			else if( expected.Length < actual.Length )
				DisplayListElements( "   extra:", actual, index, 3 );
			else
				DisplayListElements( " missing:", expected, index, 3 );
		}

8. Example

Project: 32feet
Source File: AssertionFailureMessage.cs
View license
public void DisplayArrayDifferences( Array expected, Array actual, int index )
		{
			if( expected.Length != actual.Length )
				AddLine( diffArrayLengthsFmt, expected.Length, actual.Length );
			else
				AddLine( sameArrayLengthsFmt, expected.Length );
			
			AddLine( arraysDifferAtIndexFmt, index );
				
			if ( index < expected.Length && index < actual.Length )
				DisplayDifferences( expected.GetValue( index ), actual.GetValue( index ), false );
			else if( expected.Length < actual.Length )
				DisplayListElements( "   extra:", actual, index, 3 );
			else
				DisplayListElements( " missing:", expected, index, 3 );
		}

9. Example

Project: 32feet
Source File: AssertionFailureMessage.cs
View license
protected void DisplayStringDifferences( string sExpected, string sActual, bool caseInsensitive )
		{
			//
			// If they mismatch at a specified position, report the
			// difference.
			//
			int iPosition = caseInsensitive
				? FindMismatchPosition( sExpected.ToLower(), sActual.ToLower(), 0 )
				: FindMismatchPosition( sExpected, sActual, 0 );
			//
			// If the lengths differ, but they match up to the length,
			// show the difference just past the length of the shorter
			// string
			//
			if( iPosition == -1 ) 
				iPosition = Math.Min( sExpected.Length, sActual.Length );
			
			BuildStringLengthReport( sExpected, sActual );

			AddLine( stringsDifferAtIndexFmt, iPosition );

			//
			// Clips the strings, then turns any hidden whitespace into visible
			// characters
			//
			string sClippedExpected = ConvertWhitespace(ClipAroundPosition( sExpected, iPosition ));
			string sClippedActual   = ConvertWhitespace(ClipAroundPosition( sActual,   iPosition ));

			DisplayExpectedAndActual( 
				sClippedExpected, 
				sClippedActual );

			// Add a line showing where they differ.  If the string lengths are
			// different, they start differing just past the length of the 
			// shorter string
			DisplayPositionMarker( caseInsensitive
				? FindMismatchPosition( sClippedExpected.ToLower(), sClippedActual.ToLower(), 0 )
				: FindMismatchPosition( sClippedExpected, sClippedActual, 0 ) );
		}

10. Example

Project: 32feet
Source File: AssertionFailureMessage.cs
View license
protected void DisplayStringDifferences( string sExpected, string sActual, bool caseInsensitive )
		{
			//
			// If they mismatch at a specified position, report the
			// difference.
			//
			int iPosition = caseInsensitive
				? FindMismatchPosition( sExpected.ToLower(), sActual.ToLower(), 0 )
				: FindMismatchPosition( sExpected, sActual, 0 );
			//
			// If the lengths differ, but they match up to the length,
			// show the difference just past the length of the shorter
			// string
			//
			if( iPosition == -1 ) 
				iPosition = Math.Min( sExpected.Length, sActual.Length );
			
			BuildStringLengthReport( sExpected, sActual );

			AddLine( stringsDifferAtIndexFmt, iPosition );

			//
			// Clips the strings, then turns any hidden whitespace into visible
			// characters
			//
			string sClippedExpected = ConvertWhitespace(ClipAroundPosition( sExpected, iPosition ));
			string sClippedActual   = ConvertWhitespace(ClipAroundPosition( sActual,   iPosition ));

			DisplayExpectedAndActual( 
				sClippedExpected, 
				sClippedActual );

			// Add a line showing where they differ.  If the string lengths are
			// different, they start differing just past the length of the 
			// shorter string
			DisplayPositionMarker( caseInsensitive
				? FindMismatchPosition( sClippedExpected.ToLower(), sClippedActual.ToLower(), 0 )
				: FindMismatchPosition( sClippedExpected, sClippedActual, 0 ) );
		}