Skip to content

Instantly share code, notes, and snippets.

@johnnonolan
Created April 23, 2011 12:58
Show Gist options
  • Select an option

  • Save johnnonolan/938584 to your computer and use it in GitHub Desktop.

Select an option

Save johnnonolan/938584 to your computer and use it in GitHub Desktop.
Testing Abstract Class with a mock
public class TestingAnAbstractClassWithAMock
{
[Fact]
public void Should_return_correct_message()
{
var mock = new Mock<MyAbstractClass>();
var result = mock.Object.MyMethodOnAbstractClass("fish");
Assert.Equal("I like fish in an abstract sense.", result);
}
}
public class MyAbstractClass
{
public string MyMethodOnAbstractClass(string input)
{
return "I like " + input + " in an abstract sense.";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment