public async Task Delete_Product_Should_Return_NoContent()
        {
            //Arrange
            var item = new CatalogItem {
                Id = 1, AvailableStock = 1, Name = "name"
            };

            _repository.Setup(x => x.DeleteItemAsync(item.Id)).Returns(Task.FromResult(item));

            //Act
            var actionResult = await _controller.DeleteProduct(item.Id) as NoContentResult;

            //Assert
            Assert.NotNull(actionResult);
            Assert.Equal(actionResult.StatusCode, (int)HttpStatusCode.NoContent);
        }
Пример #2
0
        public async Task DeleteProducSuccessfully()
        {
            // Arrange
            var product = DesiredProductList[0];

            _mockProductRepository.Setup(x => x.Delete(It.IsAny <string>())).ReturnsAsync(true);

            this.IntialieCatalogController();

            // Act
            var result = await _sut.DeleteProduct(product.Id);

            // Assert
            Assert.NotNull(result);
            var noContentResult = Assert.IsType <NoContentResult>(result);

            Assert.Equal(204, noContentResult.StatusCode);
        }
Пример #3
0
        public async Task TestDeleteProductSuccess()
        {
            //Should update Catalog by deleting a product from its list
            var result = await controller.AddProduct(1, 1);

            result = await controller.DeleteProduct(1, 1);

            Assert.IsType <OkObjectResult>(result);

            OkObjectResult new_res = (OkObjectResult)await controller.GetCatalog(1);

            CatalogDTO new_dto = (CatalogDTO)new_res.Value;

            //Information inside the retrived CatalogDTO should be updated
            Assert.Equal("Test_Catalog", new_dto.CatalogName);
            Assert.Equal("This is a mock Catalog", new_dto.CatalogDescription);
            Assert.Equal("06/01/2019", new_dto.Date);
            Assert.True(1 == new_dto.CatalogId);
            Assert.True(0 == new_dto.products.Count);
        }