コード例 #1
0
ファイル: UseCase1_6.cs プロジェクト: maorRoz/Sadna
 private void GuestAddToCart()
 {
     _storeGuestBridge = StoreShoppingDriver.getBridge();
     _storeGuestBridge.GetStoreShoppingService(_bridgeGuest.GetUserSession());
     _storeGuestBridge.AddProductToCart("BlahStore", "cheaps", 2);
     _storeGuestBridge.AddProductToCart("BlahStore2", "doritos", 3);
 }
コード例 #2
0
ファイル: UseCase1_5.cs プロジェクト: maorRoz/Sadna
        public void SuccessAddingProductToCartGuest()
        {
            _bridgeSignUp.EnterSystem();
            _storeBridge3 = StoreShoppingDriver.getBridge();
            _storeBridge3.GetStoreShoppingService(_bridgeSignUp.GetUserSession());
            MarketAnswer res1 = _storeBridge3.AddProductToCart("BlahStore", "bisli", 1);

            Assert.AreEqual((int)StoreEnum.Success, res1.Status);
            MarketAnswer res2 = _storeBridge3.AddProductToCart("BlahStore", "cheaps", 2);

            Assert.AreEqual((int)StoreEnum.Success, res2.Status);
            MarketAnswer res3 = _storeBridge3.AddProductToCart("BlahStore2", "doritos", 3);

            Assert.AreEqual((int)StoreEnum.Success, res3.Status);
            //Lets view to cart to see the products were indeed added.
            MarketAnswer cartDetails = _bridgeSignUp.ViewCart();

            string[] cartItemsExpected =
            {
                "Name : bisli Store : BlahStore Quantity : 1 Unit Price : 200 Final Price : 200",
                "Name : cheaps Store : BlahStore Quantity : 2 Unit Price : 20 Final Price : 40",
                "Name : doritos Store : BlahStore2 Quantity : 3 Unit Price : 30 Final Price : 90"
            };

            string[] cartItemsReceived = cartDetails.ReportList;
            Assert.AreEqual(cartItemsExpected.Length, cartItemsReceived.Length);
            for (int i = 0; i < cartItemsReceived.Length; i++)
            {
                Assert.AreEqual(cartItemsExpected[i], cartItemsReceived[i]);
            }
        }
コード例 #3
0
ファイル: UseCase1_7.cs プロジェクト: maorRoz/Sadna
 private void AddProductsToCartGuest()
 {
     _buyerGuestBridge = UserDriver.getBridge();
     _buyerGuestBridge.EnterSystem();
     _shoppingBridge2 = StoreShoppingDriver.getBridge();
     _shoppingBridge2.GetStoreShoppingService(_buyerGuestBridge.GetUserSession());
     _shoppingBridge2.AddProductToCart("Yalla", "Tea", 4);
     _shoppingBridge2.AddProductToCart("HAHAHA", "Coffee", 3);
 }
コード例 #4
0
ファイル: UseCase1_7.cs プロジェクト: maorRoz/Sadna
 private void AddProductsToCartRegisteredUser()
 {
     _buyerRegisteredUserBridge = UserDriver.getBridge();
     _buyerRegisteredUserBridge.EnterSystem();
     _buyerRegisteredUserBridge.SignUp("Shalom", "Bye", "555", "55555555");
     _shoppingBridge2 = StoreShoppingDriver.getBridge();
     _shoppingBridge2.GetStoreShoppingService(_buyerRegisteredUserBridge.GetUserSession());
     _shoppingBridge2.AddProductToCart("Yalla", "Tea", 4);
     _shoppingBridge2.AddProductToCart("HAHAHA", "Coffee", 3);
 }
コード例 #5
0
ファイル: UseCase1_5.cs プロジェクト: maorRoz/Sadna
        public void SuccessAddingProductToCartGRegisteredUser()
        {
            MarketAnswer res1 = _storeBridge.AddProductToCart("BlahStore", "bisli", 1);

            Assert.AreEqual((int)StoreEnum.Success, res1.Status);
            MarketAnswer res2 = _storeBridge.AddProductToCart("BlahStore", "cheaps", 2);

            Assert.AreEqual((int)StoreEnum.Success, res2.Status);
            MarketAnswer res3 = _storeBridge.AddProductToCart("BlahStore2", "doritos", 3);

            Assert.AreEqual((int)StoreEnum.Success, res3.Status);
            //Lets view to cart to see the products were indeed added.
            MarketAnswer cartDetails = _signInBridge.ViewCart();

            string[] cartItemsExpected =
            {
                "Name : bisli Store : BlahStore Quantity : 1 Unit Price : 200 Final Price : 200",
                "Name : cheaps Store : BlahStore Quantity : 2 Unit Price : 20 Final Price : 40",
                "Name : doritos Store : BlahStore2 Quantity : 3 Unit Price : 30 Final Price : 90"
            };

            string[] cartItemsReceived = cartDetails.ReportList;
            Assert.AreEqual(cartItemsExpected.Length, cartItemsReceived.Length);
            for (int i = 0; i < cartItemsReceived.Length; i++)
            {
                Assert.AreEqual(cartItemsExpected[i], cartItemsReceived[i]);
            }
        }
コード例 #6
0
ファイル: UseCase4_1.cs プロジェクト: maorRoz/Sadna
 private void CreateOrder()
 {
     _storeManager1.AddNewProduct("Yolo", 5, "Once", 10);
     _storeBridge.AddProductToCart("Volcano", "Yolo", 2);
     _orderBridge = OrderDriver.getBridge();
     _orderBridge.GetOrderService(_bridgeSignUp.GetUserSession());
     _orderBridge.BuyEverythingFromCart(new string[] { null });
 }
コード例 #7
0
 public MarketAnswer AddProductToCart(string store, string productName, int quantity)
 {
     if (real != null)
     {
         return(real.AddProductToCart(store, productName, quantity));
     }
     throw new NotImplementedException();
 }
コード例 #8
0
ファイル: UseCase8_3.cs プロジェクト: maorRoz/Sadna
        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);
        }
コード例 #9
0
ファイル: UseCase8_1.cs プロジェクト: maorRoz/Sadna
        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]);
            }
        }
コード例 #10
0
ファイル: UseCase1_5.cs プロジェクト: maorRoz/Sadna
        public void AddToCartInvalidUser()
        {
            //User didn't enter the system
            _storeBridge3 = StoreShoppingDriver.getBridge();
            _storeBridge3.GetStoreShoppingService(_bridgeSignUp.GetUserSession());
            MarketAnswer res1 = _storeBridge3.AddProductToCart("BlahStore", "bisli", 1);

            //TODO: when lior fixes the states - this should be invalid user
            Assert.AreEqual((int)StoreEnum.NoPermission, res1.Status);
            //the user can't even watch his cart until entering the system
            MarketAnswer cartDetails = _bridgeSignUp.ViewCart();

            Assert.AreEqual((int)ViewCartStatus.DidntEnterSystem, cartDetails.Status);
        }
コード例 #11
0
ファイル: UseCase7_1.cs プロジェクト: maorRoz/Sadna
        private void AddProductsToCartGuest()
        {
            _buyerGuestBridge = UserDriver.getBridge();
            _buyerGuestBridge.EnterSystem();
            _shoppingBridge2 = StoreShoppingDriver.getBridge();
            _shoppingBridge2.GetStoreShoppingService(_buyerGuestBridge.GetUserSession());
            _shoppingBridge2.AddProductToCart("Yalla", "Tea", 4);
            _shoppingBridge2.AddProductToCart("HAHAHA", "Coffee", 3);
            MarketAnswer cartDetails = _buyerGuestBridge.ViewCart();

            string[] received = cartDetails.ReportList;
            string[] expected =
            {
                "Name : Coffee Store : HAHAHA Quantity : 3 Unit Price : 10 Final Price : 30",
                "Name : Tea Store : Yalla Quantity : 4 Unit Price : 10 Final Price : 40"
            };

            Assert.AreEqual(expected.Length, cartDetails.ReportList.Length);
            for (int i = 0; i < received.Length; i++)
            {
                Assert.AreEqual(expected[i], received[i]);
            }
        }
コード例 #12
0
ファイル: UseCase1_5.cs プロジェクト: maorRoz/Sadna
        public void ProductQuantityNegativeGuest()
        {
            _bridgeSignUp.EnterSystem();
            _storeBridge3 = StoreShoppingDriver.getBridge();
            _storeBridge3.GetStoreShoppingService(_bridgeSignUp.GetUserSession());
            MarketAnswer res1 = _storeBridge3.AddProductToCart("BlahStore", "bisli", -5);

            Assert.AreEqual((int)StoreEnum.QuantityIsNegative, res1.Status);
            //the cart should remain empty
            MarketAnswer cartDetails = _bridgeSignUp.ViewCart();

            string[] cartItemsReceived = cartDetails.ReportList;
            string[] cartItemsExpected = { };
            Assert.AreEqual(cartItemsExpected.Length, cartItemsReceived.Length);
        }
コード例 #13
0
ファイル: UseCase1_6.cs プロジェクト: maorRoz/Sadna
 private void User1AddToCart()
 {
     _storeBridge.AddProductToCart("BlahStore", "bisli", 5);
     _storeBridge.AddProductToCart("BlahStore2", "doritos", 3);
 }
コード例 #14
0
ファイル: UseCase3_7.cs プロジェクト: maorRoz/Sadna
 private void User1AddToCart()
 {
     _storeShopping.AddProductToCart("blahblah", "hello", 5);
 }
コード例 #15
0
ファイル: UseCase5_4.cs プロジェクト: maorRoz/Sadna
 private void User2AddToCart()
 {
     _storeShopping2.AddProductToCart("blahblah", "hello2", 5);
     _storeShopping2.AddProductToCart("blahblah2", "Goodbye2", 10);
 }
コード例 #16
0
ファイル: UseCase8_3.cs プロジェクト: maorRoz/Sadna
        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]);
            }
        }