Пример #1
0
        public void simpleViewHistory()
        {
            User aviad = us.startSession();

            Assert.IsNotNull(aviad);
            int store = ss.createStore("abowim", zahi);

            Assert.IsNotNull(store);
            Assert.IsTrue(us.register(aviad, "aviad", "123456") > -1);
            Assert.IsTrue(us.login(aviad, "aviad", "123456") > -1);
            int pis    = ss.addProductInStore("cola", 3.2, 10, zahi, store, "drinks");
            int saleId = ss.addSaleToStore(zahi, store, pis, 1, 8, DateTime.Now.AddDays(10).ToString());
            LinkedList <Sale> sales = ses.viewSalesByProductInStoreId(pis);

            Assert.IsTrue(sales.Count == 1);
            Sale sale = sales.First.Value;

            Assert.IsTrue(ses.addProductToCart(aviad, sale.SaleId, 2) > -1);
            LinkedList <UserCart> sc = ses.viewCart(aviad);

            Assert.IsTrue(sc.Count == 1);
            Assert.IsTrue(sc.First.Value.getSaleId() == saleId);
            Assert.IsTrue(ses.buyProducts(aviad, "1234", ""));
            LinkedList <Purchase> historyList = ss.viewStoreHistory(zahi, store);

            Assert.IsTrue(historyList.Count == 1);
            Assert.IsTrue(historyList.First.Value.ProductId == ProductManager.getInstance().getProductInStore(pis).getProduct().getProductId());
            Assert.IsTrue(historyList.First.Value.Amount == 2);
        }