Create a gist now

Instantly share code, notes, and snippets.

What would you like to do?
[Fact]
public void Create_Person_Calls_PersonRepositoryAdd()
{
var person = new Person { BusinessEntityID = 3};
var mockpersonRepository = new Mock<IPersonRepository>();
mockpersonRepository.Setup(x => x.Add(person)); //no return as it's a void method
mockpersonRepository.Object.Add(person);
mockpersonRepository.Verify(x => x.Add(person), Times.Once()); //Assert that the Add method was called once
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment