Exemplo n.º 1
0
        public void NotPostWithNull_ReturnBadRequest()
        {
            var result  = _controller.Post(null);
            var message = ResultMessageService.GetMessage(result);

            Assert.IsType <BadRequestObjectResult>(result);
            Assert.Contains(ErrorMessages.InvalidJSON, message);
        }
Exemplo n.º 2
0
        public void NotUpdateWithMisMatchingIds_ReturnBadRequest()
        {
            var result  = _controller.Put(0, MockUser);
            var message = ResultMessageService.GetMessage(result);

            Assert.IsType <BadRequestObjectResult>(result);
            Assert.Contains(ErrorMessages.IdDoesNotMatchMessage(0), message);
        }
Exemplo n.º 3
0
        public void NotPostWithNull_ReturnBadRequest()
        {
            MockVideoService.Setup(s => s.Create(It.IsAny <VideoBO>())).Returns(new VideoBO());
            var result  = _controller.Post(null);
            var message = ResultMessageService.GetMessage(result);

            Assert.IsType <BadRequestObjectResult>(result);
            Assert.Contains(ErrorMessages.InvalidJSON, message);
        }
Exemplo n.º 4
0
        public void NotGetByNonExistingId_ReturnNotFound()
        {
            MockUserService.Setup(r => r.GetById(0)).Returns(() => null);

            var result  = _controller.Get(0);
            var message = ResultMessageService.GetMessage(result);

            Assert.IsType <NotFoundObjectResult>(result);
            Assert.Contains(ErrorMessages.IdWasNotFoundMessage(0), message);
        }
Exemplo n.º 5
0
        public void NotDeleteByNonExistingId_ReturnNotFound()
        {
            MockUserService.Setup(r => r.Delete(MockUser.Id)).Returns(false);

            var result  = _controller.Delete(MockUser.Id);
            var message = ResultMessageService.GetMessage(result);

            Assert.IsType <NotFoundObjectResult>(result);
            Assert.Contains(ErrorMessages.IdWasNotFoundMessage(MockUser.Id), message);
        }
Exemplo n.º 6
0
        public void DeleteByExistingId_ReturnOk()
        {
            MockUserService.Setup(r => r.Delete(MockUser.Id)).Returns(true);

            var result  = _controller.Delete(MockUser.Id);
            var message = ResultMessageService.GetMessage(result);

            Assert.IsType <OkObjectResult>(result);
            //Assert.Contains("Deleted", message);
        }
Exemplo n.º 7
0
        public void NotUpdateWithNonExistingId_ReturnNotFound()
        {
            MockUserService.Setup(r => r.Update(It.IsAny <UserBO>())).Returns(() => null);

            var result  = _controller.Put(MockUser.Id, MockUser);
            var message = ResultMessageService.GetMessage(result);

            Assert.IsType <NotFoundObjectResult>(result);
            Assert.Contains(ErrorMessages.IdWasNotFoundMessage(MockUser.Id), message);
        }
Exemplo n.º 8
0
        public void UpdateWithValidObject_ReturnOk()
        {
            MockGenreService.Setup(r => r.Update(It.IsAny <GenreBO>())).Returns((GenreBO updatedGenre) => updatedGenre);

            var result  = _controller.Put(MockGenre.Id, MockGenre);
            var message = ResultMessageService.GetMessage(result);

            Assert.IsType <OkObjectResult>(result);
            Assert.Contains("Updated!", message);
        }
Exemplo n.º 9
0
        public void UpdateWithValidObject_ReturnOk()
        {
            MockRentalService.Setup(r => r.Update(MockRental)).Returns(MockRental);

            var result  = _controller.Put(MockRental.Id, MockRental);
            var message = ResultMessageService.GetMessage(result);

            Assert.IsType <OkObjectResult>(result);
            Assert.Contains("Updated!", message);
        }
Exemplo n.º 10
0
        public void NotUpdateWithNonExistingId_ReturnNotFound()
        {
            MockVideoService.Setup(s => s.Update(MockVideoBO)).Returns(() => null);

            var result  = _controller.Put(MockVideoBO.Id, MockVideoBO);
            var message = ResultMessageService.GetMessage(result);

            Assert.IsType <NotFoundObjectResult>(result);
            Assert.Contains(ErrorMessages.IdWasNotFoundMessage(MockVideoBO.Id), message);
        }
Exemplo n.º 11
0
        public void NotUpdateWithMisMatchingIds_ReturnBadRequest()
        {
            MockVideoService.Setup(s => s.Update(It.IsAny <VideoBO>())).Returns(new VideoBO());

            var result  = _controller.Put(0, MockVideoBO);
            var message = ResultMessageService.GetMessage(result);

            Assert.IsType <BadRequestObjectResult>(result);
            Assert.Contains(ErrorMessages.IdDoesNotMatchMessage(0), message);
        }
Exemplo n.º 12
0
        public void UpdateWithValidObject_ReturnOk()
        {
            MockVideoService.Setup(s => s.Create(It.IsAny <VideoBO>())).Returns(new VideoBO());
            MockVideoService.Setup(s => s.Update(It.IsAny <VideoBO>())).Returns(new VideoBO());

            _controller.Post(MockVideoBO);

            MockVideoBO.Title = "Die Mega Hard";

            var updated = _controller.Put(MockVideoBO.Id, MockVideoBO);
            var message = ResultMessageService.GetMessage(updated);

            Assert.IsType <OkObjectResult>(updated);
            Assert.Contains("Updated!", message);
        }