예제 #1
0
 public int addNewDiscounts(int type, List <int> pisId, List <string> catOrProductsNames
                            , int percentage, string dueDate, string restrictions)
 {
     if (type == 1)
     {
         foreach (int pid in pisId)
         {
             Discount toAdd = new Discount(pid, 1, "", percentage, dueDate, restrictions);
             if (!DDB.Add(toAdd))
             {
                 return(-2);
             }
             discounts.AddLast(toAdd);
         }
     }
     else
     {
         foreach (string name in catOrProductsNames)
         {
             Discount toAdd = new Discount(-1, type, name, percentage, dueDate, restrictions);
             if (!DDB.Add(toAdd))
             {
                 return(-2);
             }
             discounts.AddLast(toAdd);
         }
     }
     return(1);
 }
 public void AddDiscount()
 {
     try
     {
         Discount toAdd = new Discount(2, 1, "", 20, "02/02/2030", "COUNTRY=ISRAEL");
         discountDB.Add(toAdd);
         li = discountDB.Get();
         Assert.AreEqual(li.Count, 2);
     }
     catch (Exception e)
     { Assert.AreEqual(true, false, "there was a connection error to the testing db"); }
 }
 public void init()
 {
     WebServices.DAL.CleanDB cDB = new WebServices.DAL.CleanDB();
     cDB.emptyDB();
     configuration.DB_MODE = testing;
     discountDB            = new DiscountDB(testing);
     li = new LinkedList <Discount>();
     discountDB.Add(new Discount(1, 1, "", 10, "02/02/2020", ""));
 }