public override async Task <ProductDto> GetById(string id) { try { return(WrapItem(await Task.Run(() => ProductManagementService.GetProduct(id)))); } catch (NotFoundException ex) { throw new BusinessException("Error retrieving item", ex); } catch (Exception ex) { throw new InternalException("Error retrieving item", ex); } }
public async void TestGetOneProduct() { DbContextOptions <CreaturesDbcontext> options = new DbContextOptionsBuilder <CreaturesDbcontext>().UseInMemoryDatabase("GetOneProduct").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); var res = await Service.GetProduct(2); Assert.Equal(pp, res); } }
public async Task Test02_GetProductTest() { var result = await _productManager.GetProduct(newProduct.ProductID); Assert.IsTrue(result.ProductID == newProduct.ProductID); }