Exemplo n.º 1
0
 public MarketAnswer ViewPurchaseHistoryByUser(string userName)
 {
     if (real != null)
     {
         return(real.ViewPurchaseHistoryByUser(userName));
     }
     throw new NotImplementedException();
 }
Exemplo n.º 2
0
        public void AddDiscountAndDontReceiveItBecauseDatePassed()
        {
            //check there is no discount for ouch
            CheckNoDiscountAdded();

            MarketAnswer res = _storeManagementBridge.AddDiscountToProduct("Ouch", Convert.ToDateTime("14/04/2018"), Convert.ToDateTime("15/04/2018"), 10, "HIDDEN", false);

            Assert.AreEqual((int)DiscountStatus.Success, res.Status);
            string coupon = res.ReportList[0];

            MarketYard.SetDateTime(Convert.ToDateTime("16/04/2018"));

            //check the discount was added to the product in the stock
            MarketAnswer stock = _storeShoppingBridge.ViewStoreStock("Toy");

            string[] receivedStock = stock.ReportList;
            string[] expectedStock =
            {
                " name: Ouch base price: 30 description: Ouchouch Discount: {type is: hidden} Purchase Way: Immediate Quantity: 6"
            };
            Assert.AreEqual(expectedStock.Length, receivedStock.Length);
            for (int i = 0; i < receivedStock.Length; i++)
            {
                Assert.AreEqual(expectedStock[i], receivedStock[i]);
            }

            SignUp(ref _userBuyer, "Vika", "Arad", "5555", "55555555");

            _storeShoppingBridge2 = StoreShoppingDriver.getBridge();
            _storeShoppingBridge2.GetStoreShoppingService(_userBuyer.GetUserSession());
            _storeShoppingBridge2.AddProductToCart("Toy", "Ouch", 3);

            //make sure the price in the cart is the original price
            MarketAnswer cartDetails = _userBuyer.ViewCart();

            string[] receivedItems = cartDetails.ReportList;
            string[] expectedItems =
            {
                "Name : Ouch Store : Toy Quantity : 3 Unit Price : 30 Final Price : 90",
            };
            Assert.AreEqual(expectedItems.Length, receivedItems.Length);
            for (int i = 0; i < receivedItems.Length; i++)
            {
                Assert.AreEqual(expectedItems[i], receivedItems[i]);
            }


            CreateOrderWithCouponInvalidCoupon(coupon);

            SignInAdmin("Arik1", "123");
            _userAdminBridge = AdminDriver.getBridge();
            _userAdminBridge.GetAdminService(_userAdmin.GetUserSession());
            MarketAnswer purchaseHistory = _userAdminBridge.ViewPurchaseHistoryByUser("Vika");

            //make sure the purchase didn't complete
            string[] purchaseReceived = purchaseHistory.ReportList;
            Assert.IsNull(purchaseReceived);
        }
Exemplo n.º 3
0
        public void SuccessBuyingProductsRegisterUser()
        {
            AddProductsToCartRegisteredUser();
            _orderBridge.GetOrderService(_buyerRegisteredUserBridge.GetUserSession());
            MarketAnswer res = _orderBridge.BuyEverythingFromCart(new string[] { null, null });

            Assert.AreEqual((int)OrderStatus.Success, res.Status);
            MarketAnswer puchaseHistory = _adminBridge.ViewPurchaseHistoryByUser("Shalom");

            Assert.AreEqual((int)ViewPurchaseHistoryStatus.Success, puchaseHistory.Status);
            string[] receivedHistory = puchaseHistory.ReportList;
            string[] expectedHistory =
            {
                "User: Shalom Product: Coffee Store: HAHAHA Sale: Immediate Quantity: 3 Price: 30 Date: " +
                DateTime.Now.Date.ToString("dd/MM/yyyy"),
                "User: Shalom Product: Tea Store: Yalla Sale: Immediate Quantity: 4 Price: 40 Date: " +
                DateTime.Now.Date.ToString("dd/MM/yyyy")
            };
            Assert.AreEqual(expectedHistory.Length, receivedHistory.Length);
            for (int i = 0; i < expectedHistory.Length; i++)
            {
                Assert.AreEqual(expectedHistory[i], receivedHistory[i]);
            }
            MarketAnswer cartDetails = _buyerRegisteredUserBridge.ViewCart();

            string[] expectedCart = { };
            string[] receivedCart = cartDetails.ReportList;
            Assert.AreEqual(expectedCart.Length, receivedCart.Length);
            //TODO: check the stock
            MarketAnswer stock1 = _shoppingBridge.ViewStoreStock("Yalla");

            string[] expectedYallaStock =
            {
                " name: Tea base price: 10 description: CherryFlavour Discount: {null} Purchase Way: Immediate Quantity: 2"
            };
            Assert.AreEqual(expectedYallaStock[0], stock1.ReportList[0]);
            MarketAnswer stock2 = _shoppingBridge.ViewStoreStock("HAHAHA");

            string[] expectedHahahaStock =
            {
                " name: Coffee base price: 10 description: Black Discount: {null} Purchase Way: Immediate Quantity: 3"
            };
            Assert.AreEqual(expectedHahahaStock[0], stock2.ReportList[0]);
        }
Exemplo n.º 4
0
        public void SuccessHistoryPurchaseUser()
        {
            SignIn(adminName, adminPass);
            _adminBridge.GetAdminService(_adminSignInBridge.GetUserSession());
            MarketAnswer res = _adminBridge.ViewPurchaseHistoryByUser(userToCheck);

            string[] purchaseUserHistory = res.ReportList;
            string[] expectedHistory     =
            {
                "User: Pnina Product: Goodbye Store: blahblah2 Sale: Immediate Quantity: 2 Price: 20 Date: " + DateTime.Now.Date.ToString("dd/MM/yyyy"),
                "User: Pnina Product: hello Store: blahblah Sale: Immediate Quantity: 2 Price: 20 Date: " + DateTime.Now.Date.ToString("dd/MM/yyyy")
            };

            Assert.AreEqual((int)ViewPurchaseHistoryStatus.Success, res.Status);
            for (int i = 0; i < purchaseUserHistory.Length; i++)
            {
                Assert.AreEqual(expectedHistory[i], purchaseUserHistory[i]);
            }
        }
Exemplo n.º 5
0
        public void AddDiscountAndDontReceiveItBecauseDatePassed()
        {
            //check there is no discount for ouch
            CheckNoDiscountAdded();

            MarketAnswer res = _storeManagementBridge.AddDiscountToProduct("Ouch", Convert.ToDateTime("14/04/2018"), Convert.ToDateTime("15/04/2018"), 10, "VISIBLE", false);

            Assert.AreEqual((int)DiscountStatus.Success, res.Status);

            MarketYard.SetDateTime(Convert.ToDateTime("16/04/2018"));

            //check the discount was added to the product in the stock
            MarketAnswer stock = _storeShoppingBridge.ViewStoreStock("Toy");

            string[] receivedStock = stock.ReportList;
            string[] expectedStock =
            {
                " name: Ouch base price: 30 description: Ouchouch Discount: {DiscountAmount: 10 Start Date: " + Convert.ToDateTime("14/04/2018").Date.ToString("d") + "" +
                " End Date: " + Convert.ToDateTime("15/04/2018").Date.ToString("d") + " type is: visible} Purchase Way: Immediate Quantity: 6"
            };
            Assert.AreEqual(expectedStock.Length, receivedStock.Length);
            for (int i = 0; i < receivedStock.Length; i++)
            {
                Assert.AreEqual(expectedStock[i], receivedStock[i]);
            }

            SignUp(ref _userBuyer, "Vika", "Arad", "5555", "55555555");

            _storeShoppingBridge2 = StoreShoppingDriver.getBridge();
            _storeShoppingBridge2.GetStoreShoppingService(_userBuyer.GetUserSession());
            _storeShoppingBridge2.AddProductToCart("Toy", "Ouch", 3);

            CreateOrder();

            SignInAdmin("Arik1", "123");
            _userAdminBridge = AdminDriver.getBridge();
            _userAdminBridge.GetAdminService(_userAdmin.GetUserSession());
            MarketAnswer purchaseHistory = _userAdminBridge.ViewPurchaseHistoryByUser("Vika");

            //make sure the price presented is without the discount
            string[] purchaseReceived = purchaseHistory.ReportList;
            string[] purchaseExpected =
            {
                "User: Vika Product: Ouch Store: Toy Sale: Immediate Quantity: 3 Price: 90 Date: " +
                DateTime.Now.Date.ToString("dd/MM/yyyy"),
            };
            Assert.AreEqual(purchaseExpected.Length, purchaseReceived.Length);
            for (int i = 0; i < purchaseReceived.Length; i++)
            {
                Assert.AreEqual(purchaseExpected[i], purchaseReceived[i]);
            }
        }
Exemplo n.º 6
0
 public void LotteryStillGoing()
 {
     MakeRegisteredShoppers();
     Assert.AreEqual((int)OrderStatus.Success, _orderBridge1.BuyLotteryTicket("Fanta", storeName, 1, 4).Status);
     string[] expectedHistoryFirstBuyer =
     {
         "User: Shalom1 Product: Fanta Store: LotteryStore Sale: Lottery Quantity: 1 Price: 4 Date: " + DateTime.Now.Date.ToString("dd/MM/yyyy"),
     };
     string[] actualHistoryFirstBuyer = _adminBridge.ViewPurchaseHistoryByUser("Shalom1").ReportList;
     Assert.AreEqual(expectedHistoryFirstBuyer.Length, actualHistoryFirstBuyer.Length);
     for (int i = 0; i < expectedHistoryFirstBuyer.Length; i++)
     {
         Assert.AreEqual(expectedHistoryFirstBuyer[i], actualHistoryFirstBuyer[i]);
     }
 }
Exemplo n.º 7
0
        public void AddDiscountAndReceiveItInOrderSuccessfully()
        {
            //check there is no discount for ouch
            CheckNoDiscountAdded();

            MarketAnswer res = _storeManagementBridge.AddDiscountToProduct("Ouch", Convert.ToDateTime("14/04/2018"), Convert.ToDateTime("20/04/2018"), 10, "HIDDEN", false);

            Assert.AreEqual((int)DiscountStatus.Success, res.Status);
            string coupon = res.ReportList[0];

            //check the discount was added to the product in the stock
            MarketAnswer stock = _storeShoppingBridge.ViewStoreStock("Toy");

            string[] receivedStock = stock.ReportList;
            string[] expectedStock =
            {
                " name: Ouch base price: 30 description: Ouchouch Discount: {type is: hidden} Purchase Way: Immediate Quantity: 6"
            };
            Assert.AreEqual(expectedStock.Length, receivedStock.Length);
            for (int i = 0; i < receivedStock.Length; i++)
            {
                Assert.AreEqual(expectedStock[i], receivedStock[i]);
            }


            SignUp(ref _userBuyer, "Vika", "Arad", "5555", "55555555");

            _storeShoppingBridge2 = StoreShoppingDriver.getBridge();
            _storeShoppingBridge2.GetStoreShoppingService(_userBuyer.GetUserSession());
            _storeShoppingBridge2.AddProductToCart("Toy", "Ouch", 3);


            //make sure the price in the cart is the original price
            MarketAnswer cartDetails = _userBuyer.ViewCart();

            string[] receivedItems = cartDetails.ReportList;
            string[] expectedItems =
            {
                "Name : Ouch Store : Toy Quantity : 3 Unit Price : 30 Final Price : 90",
            };
            Assert.AreEqual(expectedItems.Length, receivedItems.Length);
            for (int i = 0; i < receivedItems.Length; i++)
            {
                Assert.AreEqual(expectedItems[i], receivedItems[i]);
            }


            CreateOrderWithCoupon(coupon);

            SignInAdminSystem();
            MarketAnswer purchaseHistory = _userAdminBridge.ViewPurchaseHistoryByUser("Vika");

            //make sure the price presented is after the discount
            string[] purchaseReceived = purchaseHistory.ReportList;
            string[] purchaseExpected =
            {
                "User: Vika Product: Ouch Store: Toy Sale: Immediate Quantity: 2 Price: 40 Date: " +
                DateTime.Now.Date.ToString("dd/MM/yyyy"),
            };
            Assert.AreEqual(purchaseExpected.Length, purchaseReceived.Length);
            for (int i = 0; i < purchaseReceived.Length; i++)
            {
                Assert.AreEqual(purchaseExpected[i], purchaseReceived[i]);
            }
        }