Created
December 19, 2011 22:15
-
-
Save analogrelay/1499158 to your computer and use it in GitHub Desktop.
Mocking internal interfaces
This file contains hidden or 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
// Product Code | |
internal interface IFoo | |
{ | |
void Bar(); | |
void Baz(); | |
} |
This file contains hidden or 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
// Test Code | |
public abstract class MockableFoo : IFoo | |
{ | |
public abstract void Bar(); | |
public abstract void Baz(); | |
} | |
... | |
[Fact] | |
public void TestBar() { | |
var mock = new Mock<MockableFoo>(); | |
mock.Setup(m => m.Bar()).Returns(...); | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment