public void AddProductTest() { Factory factory = Factory.GetInstance(); // Target product------------- Product product = new Product(); product.ProductID = "MLR-100"; product.ProductName = "Milk"; product.UnitID = 1; product.QuantityReceived = 12; product.UnitPrice = 30; product.CategoryID = 1; product.Description = "Canned Milk"; product.SupplierCode = "MT-100"; //------------- try { IProductSvc productSvc = (IProductSvc)factory.GetService(typeof(IProductSvc).Name); productSvc.AddProduct(product);//adds product } catch (Exception e) { Assert.Fail(e.ToString());//force fail of test } }
public void BUpdateProductTest() { Factory factory = Factory.GetInstance(); // Target product------------- Product product = new Product(); product.ProductID = "MLR-100"; product.ProductName = "Malta"; product.UnitID = 1; product.QuantityReceived = 12; product.UnitPrice = 30; product.CategoryID = 1; product.Description = "Bottled Juice with B Vitamins"; //------------- //Add supplier for product to list try { IProductSvc productSvc = (IProductSvc)factory.GetService(typeof(IProductSvc).Name); productSvc.UpdateProduct(product);//adds product } catch (Exception e) { Assert.Fail(e.ToString());//force fail of test } }
public void BRemoveProductTest() { Factory factory = Factory.GetInstance(); Product product = new Product(); //Add supplier for product to list try { IProductSvc productSvc = (IProductSvc)factory.GetService(typeof(IProductSvc).Name); productSvc.RemoveProduct("MLR-100");//adds product } catch (Exception e) { Assert.Fail(e.ToString());//force fail of test } }
public void UpdateProduct(Product product) { try { IProductSvc productSvc = (IProductSvc)GetService(typeof(IProductSvc).Name); productSvc.UpdateProduct(product); } catch (ServiceLoadException e) { throw new ProductMgrException(e.Message); } catch (DBProcessingException e) { throw new ProductMgrException(e.Message); } }
public void RemoveProduct(string productCode) { try { IProductSvc productSvc = (IProductSvc)GetService(typeof(IProductSvc).Name); productSvc.RemoveProduct(productCode); } catch (ServiceLoadException e) { throw new ProductMgrException(e.Message); } catch (DBProcessingException e) { throw new ProductMgrException(e.Message); } }
public void AddProduct(Product product, bool isNewSupplier) { try { IProductSvc productSvc = (IProductSvc)GetService(typeof(IProductSvc).Name); productSvc.AddProduct(product, isNewSupplier); } catch (ServiceLoadException e) { throw new ProductMgrException(e.Message); } catch (DuplicateRecordException e) { throw new ProductMgrException(e.Message); } catch (DBProcessingException e) { throw new ProductMgrException(e.Message); } }
public Product SearchProduct(string productCode) { Product product = new Product(); try { IProductSvc productSvc = (IProductSvc)GetService(typeof(IProductSvc).Name); product = productSvc.SearchProduct(productCode); } catch (ServiceLoadException e) { throw new ProductMgrException(e.Message); } catch (DBProcessingException e) { throw new ProductMgrException(e.Message); } return(product); }