Last active
May 19, 2019 14:41
-
-
Save johanvergeer/3fda5518c8b97c6fa1c1045df5f22b8b to your computer and use it in GitHub Desktop.
Expect three Person objects to return
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_ReturnsAllPeople() | |
{ | |
var people = new List<Person> | |
{ | |
new Person {Name = "Johan", Age = 37}, | |
new Person {Name = "Angela", Age = 34}, | |
new Person {Name = "Robert", Age = 36} | |
}; | |
// Setup repository to return an empty list | |
this._repository.Setup(r => r.FindAll()) | |
.Returns(people); | |
// 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().HaveCount(3); | |
result.Should().BeEquivalentTo(people); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment