I'm implementing the quickstart features of Moq as a learning exercise by creating a simple console application. When I run the app I see the exception.
class Foo : IFoo
{
public bool DoSomething(string value)
{
return false;
}
}
public class Program
{
private static Mock<IFoo> mock = new Mock<IFoo>();
static void Main(string[] args)
{
mock.Setup(foo => foo.DoSomething("reset")).Throws<InvalidOperationException>();
Assert.That(() => mock.Object.DoSomething("reset"),
Throws.InvalidOperationException);
}
}
Foodoes not have any dependencies... so you don't need to mock anything to test that class. You should simply create object of Foo by doingvar foo = new Foo();