开发者

Assert.AreEqual(object, object) method

开发者 https://www.devze.com 2023-03-15 04:39 出处:网络
How does the Assert.AreEqual(object, object) method (in the namespace Microsoft.VisualStudio.TestTools.UnitTesting) determine whether the paramet开发者_如何学JAVAers are equal? Does it make use of the

How does the Assert.AreEqual(object, object) method (in the namespace Microsoft.VisualStudio.TestTools.UnitTesting) determine whether the paramet开发者_如何学JAVAers are equal? Does it make use of the Object.Equals(object, object) method (in the System namespace)?


using reflector you can see that it does indeed use Object.Equals.

public static void AreEqual<T>(T expected, T actual, string message, params object[] parameters)
{
    if (!object.Equals(expected, actual))
    {
        string str;
        if (((actual != null) && (expected != null)) && !actual.GetType().Equals(expected.GetType()))
        {
            str = (string) FrameworkMessages.AreEqualDifferentTypesFailMsg((message == null) ? string.Empty : ReplaceNulls(message), ReplaceNulls(expected), expected.GetType().FullName, ReplaceNulls(actual), actual.GetType().FullName);
        }
        else
        {
            str = (string) FrameworkMessages.AreEqualFailMsg((message == null) ? string.Empty : ReplaceNulls(message), ReplaceNulls(expected), ReplaceNulls(actual));
        }
        HandleFail("Assert.AreEqual", str, parameters);
    }
}
0

精彩评论

暂无评论...
验证码 换一张
取 消