Instantly share code, notes, and snippets.

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