Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save johanvergeer/3fda5518c8b97c6fa1c1045df5f22b8b to your computer and use it in GitHub Desktop.
Save johanvergeer/3fda5518c8b97c6fa1c1045df5f22b8b to your computer and use it in GitHub Desktop.
Expect three Person objects to return
[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