public async Task UserControllerTest_Post_returnsInternalServerError() { // Arrange _userStore.Setup(x => x.AddUser(It.IsAny <IAzureUser>())).Throws(new Exception("asd")); var user = new UserViewModel { FirstName = "Jonathan" }; // Act var controller = new UserApiController(_userStore.Object); var res = await controller.Post(user); // Assert Assert.IsInstanceOfType(res, typeof(ExceptionResult)); }
public async Task UserControllerTest_Post_returnsOk() { // Arrange var user = new UserViewModel { FirstName = "Jonathan" }; // Act var controller = new UserApiController(_userStore.Object); var res = await controller.Post(user); // Assert _userStore.Verify(x => x.AddUser(It.IsAny <IAzureUser>())); Assert.IsInstanceOfType(res, typeof(OkResult)); }
public async Task UserControllerTest_Post_returnBadRequest() { // Arrange var user = new UserViewModel { FirstName = "Jonathan" }; // Act var controller = new UserApiController(_userStore.Object); controller.ModelState.AddModelError("error", "error"); var res = await controller.Post(user); // Assert Assert.IsInstanceOfType(res, typeof(BadRequestErrorMessageResult)); }