public void simpleViewUserHistory() { User aviad = us.startSession(); Assert.IsNotNull(aviad); int storeId = ss.createStore("abowim", zahi); Store store = StoreManagement.getInstance().getStore(storeId); Assert.IsNotNull(store); Assert.IsTrue(us.register(aviad, "aviad", "123456") > -1); Assert.IsTrue(us.login(aviad, "aviad", "123456") > -1); int pisId = ss.addProductInStore("cola", 3.2, 10, zahi, store.getStoreId(), "Drink"); ProductInStore pis = ProductManager.getInstance().getProductInStore(pisId); Assert.IsNotNull(pis); int saleId = ss.addSaleToStore(zahi, store.getStoreId(), pis.getProductInStoreId(), 1, 8, DateTime.Now.AddDays(10).ToString()); LinkedList <Sale> sales = ses.viewSalesByProductInStoreId(pis.getProductInStoreId()); 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.viewUserHistory(admin, "aviad"); Assert.IsTrue(historyList.Count == 1); Assert.IsTrue(historyList.First.Value.ProductId == pis.getProduct().getProductId()); Assert.IsTrue(historyList.First.Value.Amount == 2); }
public void addNewProductInStore() { Store store = new Store(1, "halavi", null); Product milk = productArchive.addProduct("milk"); ProductInStore milkInStore = productArchive.addProductInStore(milk, store, 50, 50); Assert.IsTrue(milkInStore != null); Assert.AreEqual(milkInStore.getPrice(), 50); Assert.AreEqual(milkInStore.getProduct(), milk); Assert.AreEqual(milkInStore.getAmount(), 50); Assert.AreEqual(milkInStore.getStore(), store); }