Пример #1
0
 public void DeleteProductWillDeleteProductFromRepository(int id, [Frozen] Mock <ProductRepository> repMock, ProductManagementService sut)
 {
     // Fixture setup
     // Exercise system
     sut.DeleteProduct(id);
     // Verify outcome
     repMock.Verify(r => r.DeleteProduct(id));
     // Teardown
 }
 public void DeleteProductWillDeleteProductFromRepository(int id, [Frozen]Mock<ProductRepository> repMock, ProductManagementService sut)
 {
     // Fixture setup
     // Exercise system
     sut.DeleteProduct(id);
     // Verify outcome
     repMock.Verify(r => r.DeleteProduct(id));
     // Teardown
 }
        public async void TestdeleteProduct()
        {
            DbContextOptions <CreaturesDbcontext> options = new DbContextOptionsBuilder <CreaturesDbcontext>().UseInMemoryDatabase("DeleteProduct").Options;

            using (CreaturesDbcontext context = new CreaturesDbcontext(options))
            {
                Product p = new Product();
                p.ID = 1;
                Product pp = new Product();
                pp.ID = 2;
                ProductManagementService Service = new ProductManagementService(context);

                await Service.Create(p);

                await Service.Create(pp);

                await Service.DeleteProduct(1);

                var expect = await context.Products.FirstOrDefaultAsync(c => c.ID == 1);

                Assert.Null(expect);
            }
        }
Пример #4
0
 /// <summary>
 ///  Delate Product.
 /// </summary>
 /// <param name="product_id">Product ID</param>
 public IHttpActionResult DeleteProduct(string product_id)
 {
     return(Ok(product_service.DeleteProduct(product_id)));
 }