Skip to content

Instantly share code, notes, and snippets.

@aamiraftab
Last active May 7, 2016 07:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aamiraftab/c724b94e86430f72cba1db21fd34c572 to your computer and use it in GitHub Desktop.
Save aamiraftab/c724b94e86430f72cba1db21fd34c572 to your computer and use it in GitHub Desktop.
[Fact]
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