Exemple #1
0
        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));
        }
Exemple #2
0
        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));
        }
Exemple #3
0
        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));
        }