예제 #1
0
        public void ModifyProduct_1()
        {
            int            ExpectedOutput    = 1;
            int            GotOutput         = 0;
            ProductByStore ProductByStoreObj = new ProductByStore();

            ProductByStoreObj.SetProductByStoreID(433);
            ProductByStoreObj.SetStoreID(6);
            ProductByStoreObj.SetCategoryID(22);
            ProductByStoreObj.SetProductID(23);
            ProductByStoreObj.SetPrice(30);
            ProductByStoreObj.SetQuantity(25);
            ProductByStoreObj.SetQuantityPerUnit("test_gram");
            try
            {
                GotOutput = ProductByStoreTemplate.Update(ProductByStoreObj);
            }
            catch (Exception)
            {
                GotOutput = -2;
            }
            Assert.AreEqual(ExpectedOutput, GotOutput);
            // Modfying Product to its original values
            ProductByStoreObj.SetProductByStoreID(433);
            ProductByStoreObj.SetStoreID(5);
            ProductByStoreObj.SetCategoryID(17);
            ProductByStoreObj.SetProductID(21);
            ProductByStoreObj.SetPrice(20);
            ProductByStoreObj.SetQuantity(12);
            ProductByStoreObj.SetQuantityPerUnit("gm");
            ProductByStoreTemplate.Update(ProductByStoreObj);
        }
예제 #2
0
        public void AddProduct_1()
        {
            int            ExpectedOutput    = 1;
            int            GotOutput         = 0;
            ProductByStore ProductByStoreObj = new ProductByStore();

            ProductByStoreObj.SetStoreID(5);
            ProductByStoreObj.SetCategoryID(22);
            ProductByStoreObj.SetProductID(23);
            ProductByStoreObj.SetPrice(15);
            ProductByStoreObj.SetQuantity(25);
            ProductByStoreObj.SetQuantityPerUnit("test_gram");
            try
            {
                GotOutput = ProductByStore.Insert(ProductByStoreObj);
            }
            catch (Exception)
            {
                GotOutput = -2;
            }
            Assert.AreEqual(ExpectedOutput, GotOutput);
            // Deleting added Product
            List <IProductByStore> Output = ProductByStore.Select();

            foreach (ProductByStore Product in Output)
            {
                if ("test_gram" == Product.GetCategoryName())
                {
                    int CategoryID = Product.GetCategoryID();
                    ProductByStoreObj.SetProductByStoreID(CategoryID);
                    break;
                }
            }
            GotOutput = ProductByStore.Delete(ProductByStoreObj);
        }
예제 #3
0
 public override List <IProductByStore> Select()
 {
     Source = "sp_FetchProductByStore";
     // Product fetching stored procedure
     try
     {
         Object[] param  = null;
         DataSet  Output = Commands.ExecuteQuery(Source, CommandType.StoredProcedure, param);
         List <IProductByStore> ProductList = new List <IProductByStore>();
         foreach (DataRow dr in Output.Tables[0].Rows)
         {
             IProductByStore Product = new ProductByStore();
             Product.SetProductByStoreID(Int32.Parse(dr["pbsID"].ToString()));
             Product.SetStoreID(Int32.Parse(dr["sID"].ToString()));
             Product.SetCategoryID(Int32.Parse(dr["cID"].ToString()));
             Product.SetProductID(Int32.Parse(dr["pID"].ToString()));
             Product.SetStoreName(dr["storeName"].ToString());
             Product.SetCategoryName(dr["categoryName"].ToString());
             Product.SetProductName(dr["productName"].ToString());
             Product.SetPrice((double)dr["price"]);
             Product.SetQuantity(Int32.Parse(dr["Quantity"].ToString()));
             Product.SetQuantityPerUnit(dr["QuantityPerUnit"].ToString());
             ProductList.Add(Product);
         }
         return(ProductList);
     }
     catch (Exception ex)
     {
         Logger.Instance().Log(Fatal.Instance(), ex);
         throw ex;
     }
 }
예제 #4
0
        public void AddProduct_4()
        {
            int            ExpectedOutput    = -2;
            int            GotOutput         = 0;
            ProductByStore ProductByStoreObj = new ProductByStore();

            ProductByStoreObj.SetStoreID(5);
            ProductByStoreObj.SetCategoryID(-1);
            ProductByStoreObj.SetProductID(23);
            ProductByStoreObj.SetPrice(15);
            ProductByStoreObj.SetQuantity(25);
            ProductByStoreObj.SetQuantityPerUnit("test_gram");
            try
            {
                GotOutput = ProductByStore.Insert(ProductByStoreObj);
            }
            catch (Exception)
            {
                GotOutput = -2;
            }
            Assert.AreEqual(ExpectedOutput, GotOutput);
        }
예제 #5
0
        public void ModifyProduct_3()
        {
            int            ExpectedOutput    = -2;
            int            GotOutput         = 0;
            ProductByStore ProductByStoreObj = new ProductByStore();

            ProductByStoreObj.SetProductByStoreID(433);
            ProductByStoreObj.SetStoreID(100);
            ProductByStoreObj.SetCategoryID(22);
            ProductByStoreObj.SetProductID(23);
            ProductByStoreObj.SetPrice(30);
            ProductByStoreObj.SetQuantity(25);
            ProductByStoreObj.SetQuantityPerUnit("test_gram");
            try
            {
                GotOutput = ProductByStoreTemplate.Update(ProductByStoreObj);
            }
            catch (Exception)
            {
                GotOutput = -2;
            }
            Assert.AreEqual(ExpectedOutput, GotOutput);
        }