public void When_deleting_an_invalid_product_category_a_not_found_code_should_be_returned()
        {
            // Arrange
            var controller = new ProductCategoriesController(_logger, _repository);

            // Act
            var result = controller.Delete(-1);

            // Assert
            result.Should().BeOfType <NotFoundResult>();
        }
        public void When_deleting_a_product_category_the_query_for_that_id_should_return_a_not_found_code()
        {
            // Arrange
            var controller      = new ProductCategoriesController(_logger, _repository);
            var originalElement = ValidDataHelper.GetValidProductCategoryDto(controller);

            // Act
            var result    = controller.Delete(originalElement.Id);
            var getResult = controller.GetProductCategory(originalElement.Id);

            // Asset
            result.Should().BeOfType <NoContentResult>();
            getResult.Should().BeOfType <NotFoundResult>();
        }
示例#3
0
        public async void Delete_ReturnNotFound(int?id)
        {
            // Arrange

            var mockRepo = new Mock <IAsyncRepository <ProductCategory> >();

            mockRepo.Setup(repo => repo.GetByIdAsync(id)).ReturnsAsync(GetCategories().Find(i => i.CategId == id));

            var controller = new ProductCategoriesController(mockRepo.Object);

            // Act

            var result = await controller.Delete(id);

            // Assert

            Assert.IsType <NotFoundResult>(result);
        }
示例#4
0
        public async void Delete_DeleteItems(int?id)
        {
            // Arrange

            var mockRepo = new Mock <IAsyncRepository <ProductCategory> >();

            mockRepo.Setup(repo => repo.GetByIdAsync(id)).ReturnsAsync(GetCategories().Find(i => i.CategId == id));

            var controller = new ProductCategoriesController(mockRepo.Object);

            // Act

            var result = await controller.Delete(id);

            // Assert

            var viewResult = Assert.IsType <ViewResult>(result);
            var model      = Assert.IsAssignableFrom <ProductCategory>(viewResult.Model);

            Assert.Equal(id, model.CategId);
        }