Assert.AreEqual(object, object) method
本文关键字:object method Assert AreEqual | 更新日期: 2023-09-27 18:00:17
Assert.AreEqual(object, object)
方法(在命名空间Microsoft.VisualStudio.TestTools.UnitTesting
中)如何确定参数是否相等?它是否使用了Object.Equals(object, object)
方法(在System
命名空间中)?
使用反射器,您可以看到它确实使用了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);
}
}