Ejemplo n.º 1
0
        public void SetUp()
        {
            DbCommerce.GetInstance().StartTests();
            InitializationOfTheSystem System = new InitializationOfTheSystem();

            System.Initalize(null);
            UserId_Orel = CreateAndGetUser.CreateUser();
            UserId_Nati = CreateAndGetUser.CreateUser();
            UserId_Saar = CreateAndGetUser.CreateUser();

            Register.Registration("orel", "123456", UserId_Orel);
            LogIn.Login("orel", "123456", UserId_Orel);
            OpenStore.openStore("victory", UserId_Orel);
            OpenStore.openStore("Mega", UserId_Orel);


            ManageProducts.ManageProduct(UserId_Orel, -1, "white bread", "bread", 10, 50, "victory", "add");
            ManageProducts.ManageProduct(UserId_Orel, -1, "black bread", "bread", 15, 50, "victory", "add");
            ManageProducts.ManageProduct(UserId_Orel, -1, "chocolate", "chocolate", 11, 50, "victory", "add");
            ManageProducts.ManageProduct(UserId_Orel, -1, "milki", "dairy products", 12, 50, "Mega", "add");
            ManageProducts.ManageProduct(UserId_Orel, -1, "humus", "humus", 15, 50, "Mega", "add");
            ManageProducts.ManageProduct(UserId_Orel, -1, "water", "water", 7, 50, "Mega", "add");


            SaveProductToCart.SaveProduct(1, UserId_Orel, 10);
            SaveProductToCart.SaveProduct(2, UserId_Orel, 10);
            SaveProductToCart.SaveProduct(4, UserId_Orel, 10);
            SaveProductToCart.SaveProduct(5, UserId_Orel, 10);
            SaveProductToCart.SaveProduct(3, UserId_Nati, 10);
            SaveProductToCart.SaveProduct(6, UserId_Nati, 10);
        }
Ejemplo n.º 2
0
 public void WatchComplicatedCartTest()
 {
     SaveProductToCart.SaveProduct(1, UserId_Orel, 10);
     SaveProductToCart.SaveProduct(2, UserId_Orel, 10);
     SaveProductToCart.SaveProduct(3, UserId_Orel, 15);
     SaveProductToCart.SaveProduct(4, UserId_Orel, 20);
     WatchAndEdit.Watch(UserId_Orel);
 }
Ejemplo n.º 3
0
        public void BuyingFailed_Because_Product_isnot_Availabe_Test()
        {
            ManageProducts.ManageProduct(UserId_Orel, -1, "Hummus", "Salad", 10, 50, "Mega", "add");

            SaveProductToCart.SaveProduct(7, UserId_Orel, 40);
            SaveProductToCart.SaveProduct(7, UserId_Nati, 40);

            Assert.NotNull(ProcessOfBuyingProducts.ProcessBuyingProducts("1111114444", "11", "2019", "avi-levi", "222", "208883399", "avi", "hadkel 6", "beit shemesh", "israel", "99933", UserId_Nati));
            Assert.AreEqual(ProcessOfBuyingProducts.ProcessBuyingProducts("1111114444", "11", "2019", "avi-levi", "222", "208883399", "avi", "hadkel 6", "beit shemesh", "israel", "99933", UserId_Orel), new Tuple <int, int>(-1, -1));
        }
Ejemplo n.º 4
0
 public void NotAvailableProductShopTest()
 {
     SaveProductToCart.SaveProduct(1, UserId_Orel, 40);
     ManageProducts.ManageProduct(UserId_Orel, 1, "white bread", "bread", 10, 30, "victory", "edit");
     Assert.Throws <ErrorMessageException>(() => CheckAvailability.CheckAvailable(UserId_Orel));
 }
Ejemplo n.º 5
0
 public void AvailableFromOneShopTest()
 {
     SaveProductToCart.SaveProduct(1, UserId_Orel, 20);
     Assert.AreEqual(CheckAvailability.CheckAvailable(UserId_Orel), true);
 }
Ejemplo n.º 6
0
 public void DeleteProductsCartTest()
 {
     SaveProductToCart.SaveProduct(1, UserId_Orel, 10);
     SaveProductToCart.SaveProduct(2, UserId_Orel, 10);
     WatchAndEdit.Edit("delete", 1, UserId_Orel);
 }
Ejemplo n.º 7
0
 public void WatchSimpleCartTest()
 {
     SaveProductToCart.SaveProduct(1, UserId_Orel, 10);
     SaveProductToCart.SaveProduct(2, UserId_Orel, 10);
     WatchAndEdit.Watch(UserId_Orel);
 }
Ejemplo n.º 8
0
 public void AddNotExistedProductTest()
 {
     Assert.AreEqual(SaveProductToCart.SaveProduct(99999, UserId_Orel, 5), false);
 }
Ejemplo n.º 9
0
 public void AddProductToCartRegistedUserTest()
 {
     Assert.AreEqual(SaveProductToCart.SaveProduct(1, UserId_Orel, 5), true);
 }
Ejemplo n.º 10
0
 public void AddProductToCartNonRegisteredTest()
 {
     Assert.AreEqual(SaveProductToCart.SaveProduct(1, UserId_Nati, 10), true);
 }
        public void ReadFromStateFile(string Path)
        {
            string line;
            string FunctionName;

            try
            {
                int          userId = CreateAndGetUser.CreateUser();
                StreamReader sr     = new StreamReader(Path + ".txt");
                line = sr.ReadLine();
                while (line != null)
                {
                    string[] funcAndParam = line.Split(':');
                    FunctionName = funcAndParam[0].Trim();
                    string[] param = funcAndParam[1].Split(',');
                    switch (FunctionName)
                    {
                    case "Login":
                    {
                        LogIn.Login(param[0], param[1], userId);
                        break;
                    }

                    case "Register":
                    {
                        Register.Registration(param[0], param[1], userId);
                        break;
                    }

                    case "SaveProductToCart":
                    {
                        SaveProductToCart.SaveProduct(int.Parse(param[0]), userId, int.Parse(param[1]));
                        break;
                    }

                    case "Edit":
                    {
                        WatchAndEdit.Edit(param[0], int.Parse(param[1]), userId);
                        break;
                    }

                    case "Logout":
                    {
                        LogOut.Logout(userId);
                        break;
                    }

                    case "OpenStore":
                    {
                        OpenStore.openStore(param[0], userId);
                        break;
                    }

                    case "AssignStoreOwner":
                    {
                        AssignStoreOwner.assignStoreOwner(userId, param[1], param[2]);
                        break;
                    }

                    case "AssignStoreManager":
                    {
                        string[] boolArray  = param[3].Split(';');
                        bool[]   privileges = new bool[7];
                        int      index      = 0;
                        foreach (string X in boolArray)
                        {
                            if (X.Equals("T"))
                            {
                                privileges[index] = true;
                            }
                            else
                            {
                                privileges[index] = false;
                            }

                            index++;
                        }

                        AssignStoreManager.AsssignManager(userId, param[1], param[2], privileges);
                        break;
                    }

                    case "RemoveStoreManager":
                    {
                        RemoveStoreManager.removeStoreManager(userId, param[1], param[2]);
                        break;
                    }

                    case "AcceptAppointment":
                    {
                        HandlerRequestAppointment.AcceptAppointment(param[0], userId, param[2]);
                        break;
                    }

                    case "DeclineAppointment":
                    {
                        HandlerRequestAppointment.DeclineAppointment(param[0], userId, param[2]);
                        break;
                    }

                    case "RemoveUserFromSystem":
                    {
                        RemoveUserFromSystem.RemoveUser(userId, param[1]);
                        break;
                    }
                    }

                    line = sr.ReadLine();
                }
                sr.Close();
            }
            catch (Exception e)
            {
                Console.WriteLine("Exception: " + e.Message);
            }
        }