Last active
May 19, 2019 14:32
-
-
Save johanvergeer/ccafc0ad059dea8e01ff419eb69de555 to your computer and use it in GitHub Desktop.
Test method for PersonController returning an empty list of Person
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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