Skip to content

Instantly share code, notes, and snippets.

@hatelove
Created March 7, 2012 03:33
Show Gist options
  • Save hatelove/1990739 to your computer and use it in GitHub Desktop.
Save hatelove/1990739 to your computer and use it in GitHub Desktop.
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