private async Task<IActionResult> AddPerson(string name, string email) { var person = new AddUpdatePersonViewModel() { name = name, Email = email }; return await personController.Post(person) ; }
public async Task ShouldAddPersonAndUpdateReturnOkAndCheckIfUpdated(string name, string email, string newName) { await AddPerson(name, email); var person = new AddUpdatePersonViewModel() { name = newName, Email = email }; var actual = await personController.Put(person) as HttpStatusCodeResult; Assert.Equal((int)HttpStatusCode.OK, actual.StatusCode); var result = await personController.Get() as HttpOkObjectResult; var expected = result.Value as IList<Person>; Assert.True(expected.Any(a => a.Name == newName)); Assert.True(expected.Any(a => a.Email == email)); }
public async Task ShouldPutPersonAndCheckIfNotFound(string name, string email, string newName) { var person = new AddUpdatePersonViewModel() { name = newName, Email = email }; var actual = await personController.Put(person) as HttpStatusCodeResult; Assert.IsType<HttpNotFoundResult>(actual); }