Created
May 19, 2019 14:50
-
-
Save johanvergeer/1602b7cca1ab50b45480f1ffd0f64e98 to your computer and use it in GitHub Desktop.
Post Person object to PersonController
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 Post_Person_PersonSaved() | |
{ | |
// Create person to post to controller | |
var person = new Person {Name = "Johan", Age = 37}; | |
// Create new controller with mock repository | |
var controller = new PersonController(this._repository.Object); | |
// Call controller to post person | |
var result = controller.Post(person); | |
// Assert | |
result.Should().BeOfType<OkObjectResult>(); | |
result | |
.As<OkObjectResult>() | |
.Value.Should().Be("Person added"); | |
this._repository.Verify(r => r.Add(It.IsAny<Person>()), Times.Once()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment