Skip to content

Commit

Permalink
增加覆盖ToString,GetHashCode,Equals方法的测试用例
Browse files Browse the repository at this point in the history
bug: 目前这三个方法都是调用CLRSharp_Instance的方法
  • Loading branch information
tony-tang committed Mar 31, 2015
1 parent 997a6eb commit e337e71
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions UnitTestDll/Eviltestor/EvilTestor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,5 +91,11 @@ public static void UnitTest_11()
{
Test10.TestInnerClass();
}

public static void UnitTest_12()
{
Test12.TestOverrideObjectMethod();
}

}
}
42 changes: 42 additions & 0 deletions UnitTestDll/Eviltestor/test12/Test12.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@

using UnitTest;

/// <summary>
/// 测试覆盖系统方法
/// </summary>
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));
}
}
1 change: 1 addition & 0 deletions UnitTestDll/UnitTestDll.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@
<Compile Include="Eviltestor\test08\Test08.cs" />
<Compile Include="Eviltestor\test09\Test09.cs" />
<Compile Include="Eviltestor\test10.cs" />
<Compile Include="Eviltestor\test12\Test12.cs" />
<Compile Include="LightTestor\ExpTest_50.cs" />
<Compile Include="LightTestor\ExpTest_60.cs" />
<Compile Include="LightTestor\ExpTest_70.cs" />
Expand Down

0 comments on commit e337e71

Please sign in to comment.