コード例 #1
0
ファイル: LogicTest.cs プロジェクト: basia-224085/PT_Lab
        public void StockLogicTest()
        {
            LibraryLogic logic = new LibraryLogic(new Library());
            var          b     = new Book("Dune", "Herbert", BType.SciFi, 25, 1);

            logic.AddToStock(b);

            Assert.IsTrue(logic.GetLibrary.Stock.Contains(b));
            Assert.AreEqual(logic.GetLibrary.Stock.Count(), 1);
            Assert.IsTrue(logic.IsInStock(b));

            logic.AddToStock(b);
            Assert.AreEqual(logic.GetLibrary.Stock.Count(), 1);

            logic.RemoveFromStock(logic.GetLibrary.Stock[0]);
            Assert.AreEqual(logic.GetLibrary.Stock.Count(), 0);
        }
コード例 #2
0
ファイル: LogicTest.cs プロジェクト: basia-224085/PT_Lab
        public void AddToBasketTest()
        {
            LibraryLogic logic = new LibraryLogic(new Library());
            AbstCustomer c     = new Customer("Paul", 1, 10000);
            AbstBook     b     = new Book("Dune", "Herbert", BType.SciFi, 25, 1);

            Assert.IsFalse(logic.AddToBasket(c, b));

            logic.AddToCatalog(b);
            logic.AddToStock(b);

            Assert.IsFalse(logic.AddToBasket(c, logic.GetLibrary.Stock[0]));

            logic.AddCustomer(c);
            logic.RemoveFromStock(b);

            Assert.IsFalse(logic.AddToBasket(logic.GetLibrary.Customers[0], b));

            logic.AddToStock(b);

            Assert.IsTrue(logic.AddToBasket(logic.GetLibrary.Customers[0], logic.GetLibrary.Stock[0]));
            Assert.AreEqual(logic.GetLibrary.Customers[0].Basket.Count(), 1);
            Assert.AreEqual(logic.GetLibrary.Stock.Count(), 0);
        }