Пример #1
0
        public void AddQuanitiySuccess()
        {
            userService.EnterSystem();
            userService.SignIn("Arik1", "123");
            StoreManagementService liorSession = (StoreManagementService)market.GetStoreManagementService(userService, "X");

            liorSession.AddNewProduct("new", 5, "MOMO", 5);
            ProductToDelete = handler.GetProductFromStore(liorSession._storeName, "new");
            MarketAnswer  ans  = liorSession.AddQuanitityToProduct("new", 10);
            StockListItem find = handler.GetProductFromStore(liorSession._storeName, "new");

            Assert.AreEqual(find.Quantity, 15);
            Assert.AreEqual((int)StoreEnum.Success, ans.Status);
        }
Пример #2
0
 public void AddProductToCart(string store, string productName, int quantity)
 {
     try
     {
         MarketLog.Log("StoreCenter", "trying to add something to the cart");
         MarketLog.Log("StoreCenter", "checking if store exists");
         CheckIfStoreExitsts(store);
         MarketLog.Log("StoreCenter", "checking if user has premmisions");
         _shopper.ValidateCanBrowseMarket();
         MarketLog.Log("StoreCenter", "checking if product exists");
         CheckIsProductNameAvailableInStore(store, productName);
         StockListItem stockListItem = storeLogic.GetProductFromStore(store, productName);
         CheckifQuantityIsOK(quantity, stockListItem);
         stockListItem.CheckIfDiscountExistsAndCalcValue(store);
         _shopper.AddToCart(stockListItem.Product, stockListItem.Product.Categories, store, quantity);
         MarketLog.Log("StoreCenter", "add product successeded");
         answer = new StoreAnswer(StoreEnum.Success, quantity + " " + productName + " from " + store + "has been" +
                                  " successfully added to the user's cart!");
     }
     catch (StoreException e)
     {
         answer = new StoreAnswer((AddProductStatus)e.Status, "There is no product or store or quantity of that type in the market." +
                                  " request has been denied. Error message has been created!");
     }
     catch (DataException e)
     {
         answer = new StoreAnswer((StoreEnum)e.Status, e.GetErrorMessage());
     }
     catch (MarketException)
     {
         answer = new StoreAnswer(StoreEnum.NoPermission,
                                  "User validation as valid customer has been failed . only valid users can browse market. Error message has been created!");
     }
 }
Пример #3
0
        public void EditDiscountStartDateSuccessfully()
        {
            userService.EnterSystem();
            userService.SignIn("Arik1", "123");
            StoreManagementService liorSession = (StoreManagementService)market.GetStoreManagementService(userService, "X");

            var product = handler.GetProductFromStore("X", "BOX");

            product.Discount.startDate = DateTime.Parse("06/06/2018");
            MarketAnswer  ans  = liorSession.EditDiscount("BOX", null, false, "06/06/2018", null, null, false);
            StockListItem find = handler.GetProductFromStore("X", "BOX");

            Assert.AreEqual(find.Discount.startDate, product.Discount.startDate);
            Assert.AreEqual((int)DiscountStatus.Success, ans.Status);
        }
Пример #4
0
        public void AddProductSuccess()
        {
            userService.EnterSystem();
            userService.SignIn("Arik1", "123");
            StoreManagementService liorSession = (StoreManagementService)market.GetStoreManagementService(userService, "X");
            MarketAnswer           ans         = liorSession.AddNewProduct("item", 1, "des", 4);

            ProductToDelete = handler.GetProductFromStore("X", "item");
            Assert.AreEqual((int)StoreEnum.Success, ans.Status);
        }
Пример #5
0
        public void AddLotterySuccess()
        {
            userService.EnterSystem();
            userService.SignIn("Arik1", "123");
            StoreManagementService liorSession = (StoreManagementService)market.GetStoreManagementService(userService, "X");
            MarketAnswer           ans         = liorSession.AddNewLottery("name0", 1, "des", DateTime.Parse("30/10/2019"), DateTime.Parse("30/12/2019"));

            handler.GetProductFromStore("X", "name0");
            Assert.AreEqual((int)StoreEnum.Success, ans.Status);
        }
Пример #6
0
        public void AddDiscountsuccessfully()
        {
            userService.EnterSystem();
            userService.SignIn("Arik1", "123");
            StoreManagementService liorSession = (StoreManagementService)market.GetStoreManagementService(userService, "X");

            liorSession.AddNewProduct("item", 1, "des", 4);
            MarketAnswer ans = liorSession.AddDiscountToProduct("item", DateTime.Parse("01/01/2019"), DateTime.Parse("20/01/2019"), 10, "HIDDEN", true);

            ProductToDelete = handler.GetProductFromStore("X", "item");
            Assert.IsNotNull(ProductToDelete.Discount);
            Assert.AreEqual((int)StoreEnum.Success, ans.Status);
        }
        public void ChangeToImmediateSuccessLottery()
        {
            userService.EnterSystem();
            userService.SignIn("Arik1", "123");
            StoreManagementService liorSession = (StoreManagementService)market.GetStoreManagementService(userService, "X");
            Product P = new Product("P1345678", "OBJ", 9, "des");

            ProductToDelete = new StockListItem(4, P, null, PurchaseEnum.Lottery, "S1");
            lotteryToDelete = new LotterySaleManagmentTicket("L1000", "X", P, DateTime.Parse("31/12/2018"), DateTime.Parse("31/12/2020"));
            handler.AddStockListItemToDataBase(ProductToDelete);
            handler.AddLottery(lotteryToDelete);
            MarketAnswer  ans  = liorSession.ChangeProductPurchaseWayToImmediate("OBJ");
            StockListItem find = handler.GetProductFromStore("X", "OBJ");

            Assert.AreEqual((int)PurchaseEnum.Immediate, (int)find.PurchaseWay);
            Assert.AreEqual((int)StoreEnum.Success, ans.Status);
        }