public IActionResult Post(Application.Models.Person toPost) { var dataModel = _mapper.Map(toPost); var result = _repository.Create(dataModel); return(Ok(result)); }
public void Post_WithPersonData_CreatesNewPerson() { // Arrange var root = TestCompositionRoot.Create(); root.WithPerson(firstName: "the-test", lastName: "writer"); var controller = root.Get <PersonController>(); var toPost = new Application.Models.Person { FirstName = "new-user", LastName = "created", BirthDate = DateTime.Today.AddDays(-1) }; // Act var response = controller.Post(toPost); // Assert Assert.NotNull(response); Assert.IsType <OkObjectResult>(response); var peopleResponse = controller.Get(); var result = peopleResponse.CastValue <ICollection <Application.Models.Person> >(); Assert.Equal(2, result.Count); }