using System;
namespace NUnit.Framework
{
///
/// Asserter that verifies two objects are the same.
///
public class SameAsserter : ComparisonAsserter
{
///
/// Construct a SameAsserter object
///
/// The expected value
/// The actual value
/// A user-defined message for use in reporting errors
/// Arguments to be used in formatting the user-defined message
public SameAsserter( object expected, object actual, string message, params object[] args )
: base( expected, actual, message, args ) { }
///
/// Test that actual and expected reference the same object
///
public override bool Test()
{
#if NETCF && FX1_1 //andyh
return object_ReferenceEquals(expected, actual);
//throw new NotSupportedException("Assert.Same (ReferenceEquals) not supported on CFv1.");
#else
return object.ReferenceEquals( expected, actual );
#endif
}
#if NETCF && FX1_1 //andyh
internal static bool object_ReferenceEquals(object expected, object actual)
{
return ((object)expected == (object)actual);
}
#endif
///
/// Provide error message when the objects are different.
///
public override string Message
{
get
{
FailureMessage.AddLine( "Object instances should be the same, but are not" );
FailureMessage.DisplayExpectedAndActual( this.expected, this.actual );
return FailureMessage.ToString();
}
}
}
}