Ejemplo n.º 1
0
        public void FindAllAvailableDrinks()
        {
            //setup
            FillDataToTheDataBase();

            DrinkController dc = new DrinkController();
            BarController   bc = new BarController();

            bc.AddStockToBar(bar, new Stock()
            {
                Ingredient = TestVodkaIngre, Quantity = 100
            });


            //Act
            List <DrinkViewModel> found = controller.FindAllAvailableDrinks(bar).Values.ToList();

            //assert
            Assert.AreEqual(found.Count, 1);

            //Setup 2
            bc.AddStockToBar(bar, new Stock()
            {
                Ingredient = TestJuiceIngre, Quantity = 100
            });

            //Act 2
            List <DrinkViewModel> found2 = controller.FindAllAvailableDrinks(bar).Values.ToList();

            //assert 2
            Assert.AreEqual(found2.Count, 3);
        }
Ejemplo n.º 2
0
        public void TestFindDrinkPrice()
        {
            FillDataToTheDataBase();
            //setup

            DrinkController dc = new DrinkController();
            BarController   bc = new BarController();


            bc.AddStockToBar(bar, new Stock()
            {
                Ingredient = TestVodkaIngre, Quantity = 100
            });
            bc.AddStockToBar(bar, new Stock()
            {
                Ingredient = TestJuiceIngre, Quantity = 100
            });
            int vodkaSellingPrice = 50;
            int juiceSellingPrice = 10;

            controller.InsertDrinkPrice(bar, new Price()
            {
                BuyingPrice = 10, SellingPrice = vodkaSellingPrice, Ingredient = TestVodkaIngre
            });
            controller.InsertDrinkPrice(bar, new Price()
            {
                BuyingPrice = 2, SellingPrice = juiceSellingPrice, Ingredient = TestJuiceIngre
            });

            //act
            double priceForVodkaJuice        = controller.FindDrinkPriceById(TestVodkaJuice.Id, bar.ID);
            double ActualPriceVodkaJuice     = 0;
            QuantifiedIngredient QIngreVodka = TestVodkaJuice.Ingredients.Where(e => e.Ingredient.Id == TestVodkaIngre.Id).First();
            QuantifiedIngredient QIngreJuice = TestVodkaJuice.Ingredients.Where(e => e.Ingredient.Id == TestJuiceIngre.Id).First();

            ActualPriceVodkaJuice += vodkaSellingPrice * QIngreVodka.Quantity;
            ActualPriceVodkaJuice += juiceSellingPrice * QIngreJuice.Quantity;

            //Assert
            Assert.AreEqual(ActualPriceVodkaJuice, priceForVodkaJuice);
        }