Exemplo n.º 1
0
        // DELETE api/<controller>/5
        public HttpResponseMessage DeleteProduct(int Id)
        {
            var productServiceModel = _buildModelsService.GetProduct(Id);

            if (productServiceModel != null)
            {
                _buildModelsService.DeleteProduct(Id);
                return(ReturnResponse(productServiceModel, new JsonMediaTypeFormatter(), "application/json", HttpStatusCode.NoContent, string.Empty));
            }
            return(ReturnResponse(productServiceModel, new JsonMediaTypeFormatter(), "application/json", HttpStatusCode.NotFound, "Unable to find the product"));
        }
Exemplo n.º 2
0
        public void Delete_Product()
        {
            //Arrange
            var productName = "Deleted Sause";
            var productID   = 0;
            // We will create the product first then check its there then delete it.
            var product = new Product
            {
                ProductName  = productName,
                UnitPrice    = 2,
                SupplierID   = 1,
                CategoryID   = 1,
                UnitsInStock = 100
            };

            //Act
            var productCreated = buildModels.CreateNewProduct(product);

            productID = productCreated.ProductID;

            //Assert
            buildModels.DeleteProduct(productID).Should().Be(1);
        }