Skip to content

Instantly share code, notes, and snippets.

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 johanvergeer/ccafc0ad059dea8e01ff419eb69de555 to your computer and use it in GitHub Desktop.
Save johanvergeer/ccafc0ad059dea8e01ff419eb69de555 to your computer and use it in GitHub Desktop.
Test method for PersonController returning an empty list of Person
[Fact]
public void Get_NoArgs_ReturnsEmptyList()
{
// Setup repository to return an empty list
this._repository.Setup(r => r.FindAll())
.Returns(new List<Person>());
// Pass the mock repository to the controllers constructor
var controller = new PersonController(this._repository.Object);
// Call controller to get values
var result = controller.Get().Value;
// Assert the values
result.Should().BeOfType<List<Person>>();
result.Should().BeEmpty();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment