예제 #1
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);
        }
예제 #2
0
        private void ToCancelLottery()
        {
            var answer = orderService1.BuyLotteryTicket(productLottery, storeLottery, 1, 6);

            Assert.AreEqual(0, answer.Status);
            answer = orderService2.BuyLotteryTicket(productLottery, storeLottery, 1, 6);
            Assert.AreEqual(0, answer.Status);
            MarketYard.SetDateTime(Convert.ToDateTime("01/01/2019"));
        }
예제 #3
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]);
            }
        }
예제 #4
0
파일: UseCase8_1.cs 프로젝트: maorRoz/Sadna
 public void MarketBuilder()
 {
     MarketDB.Instance.InsertByForce();
     SignUp(ref _storeOwnerUserBridge, "Pnina", "Mishol", "7777", "77777777");
     OpenStoreAndProducts();
     _storeShoppingBridge2   = null;
     _storeManagementBridge2 = null;
     _userBuyer       = null;
     _userAdminBridge = null;
     _orderBridge     = null;
     _userAdmin       = null;
     MarketYard.SetDateTime(new DateTime(2018, 4, 13));
 }
예제 #5
0
 public void BuildStore()
 {
     marketDbMocker = new Mock <IMarketBackUpDB>();
     MarketException.SetDB(marketDbMocker.Object);
     MarketLog.SetDB(marketDbMocker.Object);
     handler     = new Mock <IStoreDL>();
     userService = new Mock <IUserSeller>();
     MarketYard.SetDateTime(new DateTime(2018, 4, 14));
     handler.Setup(x => x.GetStorebyName("X")).Returns(new Store("X", ""));
     handler.Setup(x => x.GetProductByNameFromStore("X", "item")).Returns((Product)null);
     handler.Setup(x => x.IsStoreExistAndActive("X")).Returns(true);
     slave = new AddNewProductSlave(userService.Object, "X", handler.Object);
 }
예제 #6
0
 public void BuildStore()
 {
     marketDbMocker = new Mock <IMarketBackUpDB>();
     MarketException.SetDB(marketDbMocker.Object);
     MarketLog.SetDB(marketDbMocker.Object);
     handler     = new Mock <IStoreDL>();
     userService = new Mock <IUserShopper>();
     MarketYard.SetDateTime(new DateTime(2018, 4, 14));
     prod = new Product("item", 1, "des");
     handler.Setup(x => x.GetStorebyName("X")).Returns(new Store("X", ""));
     handler.Setup(x => x.GetProductByNameFromStore("X", "item")).Returns(prod);
     handler.Setup(x => x.IsStoreExistAndActive("X")).Returns(true);
     handler.Setup(x => x.GetProductFromStore("X", "item")).Returns(new StockListItem(4, prod, null, PurchaseEnum.Immediate, "100"));
     slave = new AddProductToCartSlave(userService.Object, handler.Object);
 }
예제 #7
0
 public void BuildStore()
 {
     marketDbMocker = new Mock <IMarketBackUpDB>();
     MarketException.SetDB(marketDbMocker.Object);
     MarketLog.SetDB(marketDbMocker.Object);
     handler     = new Mock <IStoreDL>();
     userService = new Mock <IUserSeller>();
     slave       = new EditCategoryDiscountSlave("WWW", userService.Object, handler.Object);
     MarketYard.SetDateTime(new DateTime(2018, 4, 14));
     category = new Category("C0", "BLA");
     handler.Setup(x => x.GetCategoryByName("BLA")).Returns(category);
     categoryDiscount = new CategoryDiscount("d0", "BLA", "WWW", DateTime.Parse("01/01/2019"), DateTime.Parse("20/01/2019"), 10);
     handler.Setup(x => x.GetCategoryDiscount("BLA", "WWW")).Returns(categoryDiscount);
     handler.Setup(x => x.IsStoreExistAndActive("WWW")).Returns(true);
 }
예제 #8
0
        public void BuildStore()
        {
            marketDbMocker = new Mock <IMarketBackUpDB>();
            MarketException.SetDB(marketDbMocker.Object);
            MarketLog.SetDB(marketDbMocker.Object);
            handler     = new Mock <IStoreDL>();
            userService = new Mock <IUserSeller>();
            slave       = new ChangeProductPurchaseWayToLotterySlave("X", userService.Object, handler.Object);
            MarketYard.SetDateTime(new DateTime(2018, 4, 14));
            prod = new Product("item", 1, "des");
            Discount discount = new Discount(DiscountTypeEnum.Visible, DateTime.Parse("03/05/2020"), DateTime.Parse("30/06/2020"), 50, false);

            stock = new StockListItem(10, prod, discount, PurchaseEnum.Immediate, "BLA");
            handler.Setup(x => x.GetStorebyName("X")).Returns(new Store("X", ""));
            handler.Setup(x => x.GetProductByNameFromStore("X", "item")).Returns(prod);
            handler.Setup(x => x.IsStoreExistAndActive("X")).Returns(true);
            handler.Setup(x => x.GetProductFromStore("X", "item")).Returns(stock);
        }
예제 #9
0
 public void MarketBuilder()
 {
     MarketYard.SetDateTime(Convert.ToDateTime("14/04/2018"));
     MarketDB.Instance.InsertByForce();
     SignUpStoreOwner("Pnina", "mishol", "666", "66666666");
     OpenStoreAndAddProducts();
     _userAdminBridge = UserDriver.getBridge();
     _userAdminBridge.EnterSystem();
     _userAdminBridge.SignIn("Arik1", "123");
     _adminBridge = AdminDriver.getBridge();
     _adminBridge.GetAdminService(_userAdminBridge.GetUserSession());
     _buyerRegisteredUserBridge1 = null;
     _buyerRegisteredUserBridge2 = null;
     _buyerRegisteredUserBridge3 = null;
     _orderBridge1     = null;
     _orderBridge2     = null;
     _orderBridge3     = null;
     _buyerGuestBridge = null;
     PaymentService.Instance.FixExternal();
     SupplyService.Instance.FixExternal();
 }
예제 #10
0
        public void IntegrationFeedTestsBuilder()
        {
            var marketDbMocker = new Mock <IMarketBackUpDB>();

            MarketException.SetDB(marketDbMocker.Object);
            MarketLog.SetDB(marketDbMocker.Object);
            countMessagesToServer = 0;
            serverMocker          = new Mock <IListener>();
            serverMocker.Setup(x => x.GetMessage(buyerId1.ToString(), "You have been fully refunded on a lottery you " +
                                                 "were participating on")).Callback(SendMessageToServer);
            serverMocker.Setup(x => x.GetMessage(buyerId2.ToString(), "You have been fully refunded on a lottery you " +
                                                 "were participating on")).Callback(SendMessageToServer);
            MarketDB.Instance.InsertByForce();
            var marketSession = MarketYard.Instance;
            var userService1  = marketSession.GetUserService();

            orderService1 = (OrderService)marketSession.GetOrderService(ref userService1);
            orderService1.LoginBuyer("Ryder", "123");
            var userService2 = marketSession.GetUserService();

            orderService2 = (OrderService)marketSession.GetOrderService(ref userService2);
            orderService2.LoginBuyer("Vadim Chernov", "123");
            MarketYard.SetDateTime(Convert.ToDateTime("14/04/2018"));
        }
예제 #11
0
파일: UseCase8_3.cs 프로젝트: maorRoz/Sadna
 public void UserTestCleanUp()
 {
     MarketYard.SetDateTime(Convert.ToDateTime("14/04/2018"));
     MarketDB.Instance.CleanByForce();
     MarketYard.CleanSession();
 }