Skip to content

Instantly share code, notes, and snippets.

@erikdietrich
Last active December 14, 2015 00:19
Show Gist options
  • Save erikdietrich/4998372 to your computer and use it in GitHub Desktop.
Save erikdietrich/4998372 to your computer and use it in GitHub Desktop.
Demonstration of the Mock/regular conflict in Moq
private ISomeService Service { get; set; }
[TestMethod, Owner("ebd"), TestCategory("Proven"), TestCategory("Unit")]
public void SomeTest()
{
Service = Mock.Of<ISomeService>();
//I want to inject it as if it were just some service
Target = new SomeClassUnderTest(Service);
//But then I want to configure the meta-behavior around the mock also
Mock.Get(Service).Setup(serv => serv.Create(It.IsAny<Entity>())).Throws(new Exception());
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment