public void AddProductOnly_1() { int ExpectedOutput = 1; int GotOutput = 0; CRUDTemplate <IProduct> ProductTemplateObj = new ProductTemplate(); ProductsOnly ProductsOnlyObj = new ProductsOnly(); ProductsOnlyObj.SetProductName("Test_Product"); ProductsOnlyObj.SetProductImage("images\test.png"); try { GotOutput = ProductTemplateObj.Insert(ProductsOnlyObj); } catch (Exception) { GotOutput = -2; } Assert.AreEqual(ExpectedOutput, GotOutput); // deleting the Product by product id List <IProduct> Output = ProductTemplateObj.Select(); foreach (IProduct Product in Output) { if ("Test_Product" == Product.GetProductImage()) { int ProductId = Product.GetProductId(); ProductsOnlyObj.SetProductId(ProductId); break; } } ProductTemplateObj.Delete(ProductsOnlyObj); }
public override List <IProduct> Select() { Source = "sp_FetchProductOnly"; // Product fetching stored procedure try { Object[] param = null; DataSet Output = Commands.ExecuteQuery(Source, CommandType.StoredProcedure, param); List <IProduct> ProductList = new List <IProduct>(); foreach (DataRow dr in Output.Tables[0].Rows) { IProduct Product = new ProductsOnly(); Product.SetProductId(Int32.Parse(dr["pID"].ToString())); Product.SetProductName(dr["productName"].ToString()); Product.SetProductImage(dr["productImage"].ToString()); ProductList.Add(Product); } return(ProductList); } catch (Exception ex) { Logger.Instance().Log(Fatal.Instance(), ex); throw ex; } }