diff --git a/UnitTestDll/Eviltestor/EvilTestor.cs b/UnitTestDll/Eviltestor/EvilTestor.cs index d5514cc..709c2ce 100644 --- a/UnitTestDll/Eviltestor/EvilTestor.cs +++ b/UnitTestDll/Eviltestor/EvilTestor.cs @@ -91,5 +91,11 @@ public static void UnitTest_11() { Test10.TestInnerClass(); } + + public static void UnitTest_12() + { + Test12.TestOverrideObjectMethod(); + } + } } diff --git a/UnitTestDll/Eviltestor/test12/Test12.cs b/UnitTestDll/Eviltestor/test12/Test12.cs new file mode 100644 index 0000000..1d98cf7 --- /dev/null +++ b/UnitTestDll/Eviltestor/test12/Test12.cs @@ -0,0 +1,42 @@ + +using UnitTest; + +/// +/// 测试覆盖系统方法 +/// +public class Test12 +{ + public string Name; + public int Age; + + public override string ToString() + { + return string.Format("Name:{0}, Age:{1}", Name, Age); + } + + public override bool Equals(object obj) + { + if (!(obj is Test12)) + { + return false; + } + var o = (Test12) obj; + return Name == o.Name && Age == o.Age; + } + + public override int GetHashCode() + { + //for test + return 123456789; + } + + public static void TestOverrideObjectMethod() + { + Test12 t1 = new Test12 {Name = "Test1", Age = 18}; + Test12 t2 = new Test12 {Name = "Test1", Age = 18}; + + Logger.Log("t1.ToString(): " + t1); + Logger.Log("t1.GetHashCode(): " + t1.GetHashCode()); + Logger.Log("t1.Equals(t2): " + t1.Equals(t2)); + } +} diff --git a/UnitTestDll/UnitTestDll.csproj b/UnitTestDll/UnitTestDll.csproj index 5e45a84..7d8af27 100644 --- a/UnitTestDll/UnitTestDll.csproj +++ b/UnitTestDll/UnitTestDll.csproj @@ -49,6 +49,7 @@ +