Created
March 7, 2012 03:33
-
-
Save hatelove/1990739 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Target | |
{ | |
private delegate int MyDelegate(); | |
public int MyMethod(int original) | |
{ | |
MyDelegate mydelegate = new DelegateSource().DelegateOne; | |
var mod = mydelegate(); | |
return original % mod; | |
} | |
} | |
public class DelegateSource | |
{ | |
public int DelegateOne() | |
{ | |
var result = GetMyValue(); | |
return result; | |
} | |
private int GetMyValue() | |
{ | |
return 2; | |
} | |
} | |
//=============測試============= | |
/// <summary> | |
///MyMethod 的測試 | |
///</summary> | |
[TestMethod()] | |
public void MyMethodTest() | |
{ | |
Target target = new Target(); | |
int original = 3; | |
int expected = 1; | |
int actual; | |
actual = target.MyMethod(original); | |
Assert.AreEqual(expected, actual); | |
} | |
/// <summary> | |
///MyMethod 的測試 | |
///</summary> | |
[TestMethod()] | |
public void MyMethodTest_2() | |
{ | |
Target target = new Target(); | |
int original = 2; | |
int expected = 0; | |
int actual; | |
actual = target.MyMethod(original); | |
Assert.AreEqual(expected, actual); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment