コード例 #1
0
        public void Delete_NonExistUser_ShouldReturnNotFound()
        {
            //arrange
            User user = TestDataHelper.GenerateUser();
            var userController = new UserController(TestDataHelper.GetIUserRepositoryMock(null));

            //act
            IHttpActionResult response = userController.Delete(user.Id);

            //assert
            Assert.IsTrue(response is NotFoundResult);
        }
コード例 #2
0
        public void Create_WithNullUserObject_ShouldReturnBadRequest()
        {
            //arrange
            User user = null;
            var userController = new UserController(TestDataHelper.GetIUserRepositoryMock(user));

            //act
            IHttpActionResult response = userController.Create(user);

            //assert
            Assert.IsTrue(response is BadRequestErrorMessageResult);
        }
コード例 #3
0
        public void Create_ShouldReturnCreated()
        {
            //arrange
            User user = TestDataHelper.GenerateUser();
            var userController = new UserController(TestDataHelper.GetIUserRepositoryMock(null));

            //act
            IHttpActionResult response = userController.Create(user);

            //assert
            Assert.IsTrue(response is CreatedNegotiatedContentResult<User>);
        }
コード例 #4
0
        public void Delete_ShouldReturnOk()
        {
            //arrange
            User user = TestDataHelper.GenerateUser();
            var userController = new UserController(TestDataHelper.GetIUserRepositoryMock(user));

            //act
            userController.Create(user);
            IHttpActionResult response = userController.Delete(user.Id);

            //assert
            Assert.IsTrue(response is OkResult);
        }
コード例 #5
0
        public void Update_WithNullField_ShouldReturnBadRequest()
        {
            //arrange
            User user = TestDataHelper.GenerateUser();
            user.Email = null;
            var userController = new UserController(TestDataHelper.GetIUserRepositoryMock(user));

            //act
            IHttpActionResult response = userController.Update(user);

            //assert
            Assert.IsTrue(response is BadRequestErrorMessageResult);
        }
コード例 #6
0
        public void Get_ById_ShouldReturnOk()
        {
            //arrange
            User user = TestDataHelper.GenerateUser();
            var userController = new UserController(TestDataHelper.GetIUserRepositoryMock(user));

            //act
            IHttpActionResult response = userController.Get(user.Id.ToString());

            //assert
            Assert.IsTrue(response is OkNegotiatedContentResult<User>);
        }