Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
public void Get_Person_By_Id()
var person = new Person { BusinessEntityID = 3};
var mockpersonRepository = new Mock();
mockpersonRepository.Setup(x => x.GetPersonById(3))
.Returns(person); //return Person
mockpersonRepository.Object.GetPersonById(3).ShouldBe(person); //Assert expected value equal to actual value
mockpersonRepository.Verify(x => x.GetPersonById(person.BusinessEntityID), Times.Once()); //Assert that the Get method was called once
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.