Created
January 29, 2014 18:36
-
-
Save sharwell/8694092 to your computer and use it in GitHub Desktop.
The assertions in the test method all pass. Read carefully :)
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
[TestMethod] | |
public void TestCalls() | |
{ | |
FooDerived foo = new FooDerived(); | |
Func<int> method = foo.Bar; | |
Assert.AreEqual(1, method()); | |
method = foo.FooBar(); | |
Assert.AreEqual(1, method()); | |
method = foo.BaseFooBar(); | |
Assert.AreEqual(0, method()); | |
} | |
class Foo | |
{ | |
public virtual int Bar() | |
{ | |
return 0; | |
} | |
public virtual Func<int> FooBar() | |
{ | |
return Bar; | |
} | |
public virtual Func<int> BaseFooBar() | |
{ | |
return Bar; | |
} | |
} | |
class FooDerived : Foo | |
{ | |
public override int Bar() | |
{ | |
return 1; | |
} | |
public override Func<int> BaseFooBar() | |
{ | |
return base.Bar; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment