예제 #1
0
        public void CheckIfDrinkNameExists()
        {
            //setup
            DrinkDB       drinkDB = new DrinkDB();
            List <String> names   = new List <string>();

            names.Add("testJuiceVodka");

            Ingredient testVodka = new Ingredient("testVodka", true, 37);
            Ingredient testJuice = new Ingredient("testJuice", true, 0);

            IngredientDB ingredientDB = new IngredientDB();

            ingredientDB.Insert(testVodka);
            ingredientDB.Insert(testJuice);

            MeasurementDB measurementDB = new MeasurementDB();

            Measurement measurement = measurementDB.Find("cl");

            QuantifiedIngredient quantifiedIngredientVodka = new QuantifiedIngredient(8, testVodka, measurement);
            QuantifiedIngredient quantifiedIngredientJuice = new QuantifiedIngredient(16, testJuice, measurement);

            List <QuantifiedIngredient> quantifiedIngredientsList = new List <QuantifiedIngredient>();

            quantifiedIngredientsList.Add(quantifiedIngredientVodka);
            quantifiedIngredientsList.Add(quantifiedIngredientJuice);

            Drink drink = new Drink(names, quantifiedIngredientsList, "Bland");

            Drink drinkWithId = drinkDB.Insert(drink);

            drinkDB.InsertDrinkNames(names.First(), drinkWithId.Id);

            QuantifiedIngredientDB quantifiedIngredientDB = new QuantifiedIngredientDB();

            quantifiedIngredientDB.Insert(quantifiedIngredientsList, drinkWithId.Id);

            //act
            bool drinkNameExists = drinkDB.CheckDrinkName(drinkWithId.Names.First());

            //assert
            Assert.AreEqual(drinkNameExists, true);
        }
예제 #2
0
 public Ingredient Create(Ingredient ingredient)
 {
     return(ingredientDB.Insert(ingredient));
 }