예제 #1
0
        public void TestLogic()
        {
            ShopLogic      shopLogic = new ShopLogic();
            DataGeneration datagen   = new DataGeneration();

            shopLogic.ParseData(datagen.GiveData());

            Assert.IsTrue(shopLogic.IsInStock("Chocolate"));
            Assert.IsTrue(shopLogic.IsInStock("Bun"));
            Assert.IsTrue(shopLogic.IsInStock("Cheese"));
            Assert.IsTrue(shopLogic.IsInCatalog("Eggs"));
            Assert.IsTrue(shopLogic.IsInCatalog("Water"));
            Assert.IsTrue(shopLogic.IsInCatalog("Milk"));
            Assert.IsTrue(shopLogic.IsInShop("Mark"));
            Assert.IsTrue(shopLogic.IsInShop("Cody"));
            Assert.IsTrue(shopLogic.IsInShop("Anna"));

            shopLogic.AddToBasket(shopLogic.shop.Clients[1], shopLogic.shop.Stock[0]);
            shopLogic.AddToBasket(shopLogic.shop.Clients[1], shopLogic.shop.Stock[4]);

            Assert.IsTrue(shopLogic.ValueOfBasket(shopLogic.shop.Clients[1]) == 5.20);
            Assert.IsFalse(shopLogic.Checkout(shopLogic.shop.Clients[1]));

            shopLogic.RemoveFromBasket(shopLogic.shop.Clients[1], shopLogic.shop.Clients[1].Basket[1]);
            shopLogic.AddToBasket(shopLogic.shop.Clients[1], shopLogic.shop.Stock[1]);

            Assert.IsTrue(shopLogic.Checkout(shopLogic.shop.Clients[1]));
            Assert.IsTrue(shopLogic.IsInStock("Ice Cream"));
            Assert.IsFalse(shopLogic.IsInStock("Water"));
        }