Example #1
0
        public void ReturnNotFoundForDelete()
        {
            _sut = new ProductManagerController(_mockProductRepository.Object, _mockProductCategoryRepository.Object,
                                                _mockEnvironment.Object);

            IActionResult result = _sut.Delete("abc123");

            Assert.IsType <NotFoundResult>(result);
        }
        public void Delete_Success()
        {
            // Arrange
            ProductManagerController controller = new ProductManagerController();
            // Act
            // var redirectToRouteResult = controller.Delete(1083) as RedirectToRouteResult;
            ViewResult result = controller.Delete(0) as ViewResult;

            // Assert
            Assert.IsNull(result);
        }
Example #3
0
        public void ReturnDeleteWithProduct()
        {
            _mockProductRepository.Setup(products => products.Find("abc123")).Returns(GetProduct());

            _sut = new ProductManagerController(_mockProductRepository.Object, _mockProductCategoryRepository.Object,
                                                _mockEnvironment.Object);

            IActionResult result = _sut.Delete("abc123");

            var viewResult = Assert.IsType <ViewResult>(result);

            var model = Assert.IsType <Product>(viewResult.Model);

            Assert.Equal((string)GetProduct().Category, model.Category);
            Assert.Equal((string)GetProduct().Id, model.Id);
            Assert.Equal(GetProduct().CreatedAt.Minute, model.CreatedAt.Minute);
            Assert.Equal((string)GetProduct().Description, model.Description);
            Assert.Equal((string)GetProduct().Name, model.Name);
            Assert.Equal(GetProduct().Price, model.Price);
            Assert.Equal((string)GetProduct().Image, model.Image);
        }