public Menu MakeMenu()
        {
            Facade facade = new Facade();

            Ingredient ing1 = new Ingredient() { Name = "ing1", Price = 10 };
            Ingredient ing2 = new Ingredient() { Name = "ing2", Price = 12 };
            Ingredient ing3 = new Ingredient() { Name = "ing3", Price = 13 };
            Ingredient ing4 = new Ingredient() { Name = "ing4", Price = 15 };

            ing1 = facade.IngredientRepo().Add(ing1);
            ing2 = facade.IngredientRepo().Add(ing2);
            ing3 = facade.IngredientRepo().Add(ing3);
            ing4 = facade.IngredientRepo().Add(ing4);

            Dish dish1 = new Dish() { Description = "descrip 1", Name = "dish1", Status = 0, Ingredients = new List<Ingredient>() { ing1, ing2 } };
            Dish dish2 = new Dish() { Description = "descrip 2", Name = "dish2", Status = 1, Ingredients = new List<Ingredient>() { ing3, ing4 } };
            Dish dish3 = new Dish() { Description = "descrip 3", Name = "dish3", Status = 3, Ingredients = new List<Ingredient>() {ing1, ing2, ing3, ing4 } };

            dish1 = facade.DishRepo().Add(dish1);
            dish2 = facade.DishRepo().Add(dish2);
            dish3 = facade.DishRepo().Add(dish3);

            Menu menu = new Menu() { Dishes = new List<Dish> { dish1, dish2, dish3 }, Name = "menu1" };
            menu = facade.MenuRepo().Add(menu);
            return menu;
        }
        public void Dish_getall_includes_ingredients_test()
        {
            Facade facade = new Facade();
            Ingredient ing = new Ingredient()
            {
                Name = "ing1",
                Price = 200
            };
            Ingredient ing2 = new Ingredient()
            {
                Name = "ing2",
                Price = 200
            };
            ing = facade.IngredientRepo().Add(ing);
            ing2 = facade.IngredientRepo().Add(ing2);

            List<Ingredient> list = new List<Ingredient>();
            list.Add(ing);
            list.Add(ing2);

            facade = new Facade();
            Dish dish = new Dish()
            {
                Description = "asd",
                Ingredients = list,
                Name = "dish1",
                Status = 0
            };
            dish = facade.DishRepo().Add(dish);
            facade = new Facade();

            Assert.AreEqual(facade.DishRepo().GetAll().ToList().FirstOrDefault(x => x.Id == dish.Id).Ingredients.Count, 2);
        }
        public void Menu_add_throws_exception_on_updated_dish_test()
        {
            Facade facade = new Facade();

            Ingredient ing1 = new Ingredient() { Name = "ing1", Price = 10 };
            Ingredient ing2 = new Ingredient() { Name = "ing2", Price = 12 };
            Ingredient ing3 = new Ingredient() { Name = "ing3", Price = 13 };
            Ingredient ing4 = new Ingredient() { Name = "ing4", Price = 15 };

            ing1 = facade.IngredientRepo().Add(ing1);
            ing2 = facade.IngredientRepo().Add(ing2);
            ing3 = facade.IngredientRepo().Add(ing3);
            ing4 = facade.IngredientRepo().Add(ing4);

            Dish dish1 = new Dish() { Description = "descrip 1", Name = "dish1", Status = 0, Ingredients = new List<Ingredient>() { ing1, ing2 } };
            Dish dish2 = new Dish() { Description = "descrip 2", Name = "dish2", Status = 1, Ingredients = new List<Ingredient>() { ing3, ing4 } };
            Dish dish3 = new Dish() { Description = "descrip 3", Name = "dish3", Status = 3, Ingredients = new List<Ingredient>() { ing1, ing2, ing3, ing4 } };

            dish1 = facade.DishRepo().Add(dish1);
            dish2 = facade.DishRepo().Add(dish2);
            dish3 = facade.DishRepo().Add(dish3);
            dish1.Name = "changed";
            Menu menu = new Menu() { Dishes = new List<Dish> { dish1, dish2, dish3 }, Name = "menu1" };
            menu = facade.MenuRepo().Add(menu);
        }
        public void Ingredient_getall_returns_multiple_test()
        {
            Facade facade = new Facade();
            Ingredient ing = new Ingredient()
            {
                Name = "hestkød",
                Price = 200
            };
            facade.IngredientRepo().Add(ing);
            ing = facade.IngredientRepo().Add(ing);

            facade = new Facade();
            Assert.GreaterOrEqual(facade.IngredientRepo().GetAll().ToList().Count, 2);
        }
        public void Ingredient_get_returns_all_values_correctly_test()
        {
            Facade facade = new Facade();
            Ingredient ing = new Ingredient()
            {
                Name = "hestkød",
                Price = 200
            };
            ing = facade.IngredientRepo().Add(ing);

            facade = new Facade();
            Assert.AreEqual(facade.IngredientRepo().Get(ing.Id).Name, ing.Name);
            Assert.AreEqual(facade.IngredientRepo().Get(ing.Id).Price, ing.Price);
        }
        public Party MakeParty()
        {
            Facade facade = new Facade();

            Ingredient ing1 = new Ingredient() { Name = "ing1", Price = 10 };
            Ingredient ing2 = new Ingredient() { Name = "ing2", Price = 12 };
            Ingredient ing3 = new Ingredient() { Name = "ing3", Price = 13 };
            Ingredient ing4 = new Ingredient() { Name = "ing4", Price = 15 };

            ing1 = facade.IngredientRepo().Add(ing1);
            ing2 = facade.IngredientRepo().Add(ing2);
            ing3 = facade.IngredientRepo().Add(ing3);
            ing4 = facade.IngredientRepo().Add(ing4);

            Dish dish1 = new Dish() { Description = "descrip 1", Name = "dish1", Status = 0, Ingredients = new List<Ingredient>() { ing1, ing2 } };
            Dish dish2 = new Dish() { Description = "descrip 2", Name = "dish2", Status = 1, Ingredients = new List<Ingredient>() { ing3, ing4 } };
            Dish dish3 = new Dish() { Description = "descrip 3", Name = "dish3", Status = 3, Ingredients = new List<Ingredient>() { ing1, ing2, ing3, ing4 } };

            dish1 = facade.DishRepo().Add(dish1);
            dish2 = facade.DishRepo().Add(dish2);
            dish3 = facade.DishRepo().Add(dish3);

            Menu menu = new Menu() { Dishes = new List<Dish> { dish1, dish2, dish3 }, Name = "menu1" };
            Menu menu2 = new Menu() { Dishes = new List<Dish> { dish1, dish2 }, Name = "menu2" };
            menu = facade.MenuRepo().Add(menu);
            menu2 = facade.MenuRepo().Add(menu2);

            Address address = new Address() { Country = "Denmark", StreetAddress = "Møbelvej 3", ZipCode = "6800" };
            Address address2 = new Address() { Country = "Denmark", StreetAddress = "gyvelunden 3", ZipCode = "6800" };
            address = facade.AddressRepo().Add(address);
            address2 = facade.AddressRepo().Add(address2);

            Customer cus = new Customer(){Address = address, Email = "*****@*****.**",FirstName = "Jonas",LastName = "Olesen",PhoneNumber = "22342312"};
            cus = facade.CustomerRepo().Add(cus);

            Party party = new Party()
            {
                Address = address2,
                Customer = cus,
                CreationDate = DateTime.Now.AddYears(-2),
                Description = "Description",
                FestNummer = "1",
                Menus = new List<Menu>() { menu, menu2 },
                UseDate = DateTime.Now.AddMonths(-1)
            };
            party = facade.PartyRepo().Add(party);
            return party;
        }
        public void Dish_add_throws_exception_on_updated_ingredient_test()
        {
            Facade facade = new Facade();

            Ingredient ing2 = new Ingredient()
            {
                Name = "ing2",
                Price = 200
            };

            ing2 = facade.IngredientRepo().Add(ing2);

            ing2.Name = "Changed";
            List<Ingredient> list = new List<Ingredient>();
            list.Add(ing2);

            facade = new Facade();
            Dish dish = new Dish()
            {
                Description = "asd",
                Ingredients = list,
                Name = "dish1",
                Status = 0
            };
            dish = facade.DishRepo().Add(dish);
        }
        public void Ingredient_adds_on_call_test()
        {
            Facade facade = new Facade();
            Ingredient ing = new Ingredient()
            {
                Name = "hestkød",
                Price = 200
            };
            ing = facade.IngredientRepo().Add(ing);

            facade = new Facade();
            Assert.AreEqual(facade.IngredientRepo().Get(ing.Id).Name, ing.Name);
        }
        public void Ingredient_remove_removes_right_one_test()
        {
            Facade facade = new Facade();
            Ingredient ing = new Ingredient()
            {
                Name = "hestkød",
                Price = 200
            };
            ing = facade.IngredientRepo().Add(ing);

            facade = new Facade();
            facade.IngredientRepo().Remove(ing.Id);

            facade = new Facade();
            Assert.IsNull(facade.IngredientRepo().Get(ing.Id));
        }
        public void Dish_update_throws_exception_on_updated_ingredient_test()
        {
            Facade facade = new Facade();
            Ingredient ing2 = new Ingredient()
            {
                Name = "ing1",
                Price = 200
            };
            ing2 = facade.IngredientRepo().Add(ing2);
            List<Ingredient> list = new List<Ingredient>();
            list.Add(ing2);

            facade = new Facade();
            Dish dish = new Dish()
            {
                Description = "asd",
                Ingredients = list,
                Name = "dish1",
                Status = 0
            };
            dish = facade.DishRepo().Add(dish);
            facade = new Facade();
            dish.Ingredients.FirstOrDefault().Name = "ing4";

            facade.DishRepo().Update(dish);
        }
 public void Ingredient_add_throws_exception_on_item_equals_null_test()
 {
     Facade facade = new Facade();
     facade.IngredientRepo().Add(null);
 }
 public void Ingredient_update_throws_exception_on_null_test()
 {
     Facade facade = new Facade();
     facade.IngredientRepo().Update(null);
 }
        public void Dish_same_ingredient_on_multiple_dishes_test()
        {
            Facade facade = new Facade();
            Ingredient ing = new Ingredient()
            {
                Name = "ing1",
                Price = 200
            };
            Ingredient ing2 = new Ingredient()
            {
                Name = "ing2",
                Price = 200
            };
            ing = facade.IngredientRepo().Add(ing);
            ing2 = facade.IngredientRepo().Add(ing2);

            List<Ingredient> list = new List<Ingredient>();
            list.Add(ing);
            list.Add(ing2);

            facade = new Facade();
            Dish dish = new Dish()
            {
                Description = "asd",
                Ingredients = list,
                Name = "dish1",
                Status = 0
            }; Dish dish2 = new Dish()
            {
                Description = "as2d",
                Ingredients = list,
                Name = "dish1",
                Status = 0
            };
            dish = facade.DishRepo().Add(dish);
            dish2 = facade.DishRepo().Add(dish2);

            Assert.Contains(ing, dish.Ingredients);
            Assert.Contains(ing, dish2.Ingredients);
        }
        public void Dish_update_updates_added_ingredients_test()
        {
            Facade facade = new Facade();
            Ingredient ing = new Ingredient()
            {
                Name = "ing1",
                Price = 200
            };
            Ingredient ing2 = new Ingredient()
            {
                Name = "ing2",
                Price = 200
            };
            ing = facade.IngredientRepo().Add(ing);
            ing2 = facade.IngredientRepo().Add(ing2);

            List<Ingredient> list = new List<Ingredient>();
            list.Add(ing);
            list.Add(ing2);

            facade = new Facade();
            Dish dish = new Dish()
            {
                Description = "asd",
                Ingredients = list,
                Name = "dish1",
                Status = 0
            };
            dish = facade.DishRepo().Add(dish);

            facade = new Facade();
            Ingredient ing3 = new Ingredient()
            {
                Name = "ing3",
                Price = 200
            };
            ing3 = facade.IngredientRepo().Add(ing3);
            dish.Ingredients.Add(ing3);

            Assert.IsTrue(facade.DishRepo().Update(dish));

            Assert.AreEqual(facade.DishRepo().Get(dish.Id).Ingredients.Count, 3);
        }
 public void Ingredient_remove_throws_new_exception_on_null_test()
 {
     Facade facade = new Facade();
     facade.IngredientRepo().Remove(-1);
 }
        public void Dish_update_updates_properties_test()
        {
            Facade facade = new Facade();
            Ingredient ing = new Ingredient()
            {
                Name = "ing1",
                Price = 200
            };
            Ingredient ing2 = new Ingredient()
            {
                Name = "ing2",
                Price = 200
            };
            ing = facade.IngredientRepo().Add(ing);
            ing2 = facade.IngredientRepo().Add(ing2);

            List<Ingredient> list = new List<Ingredient>();
            list.Add(ing);
            list.Add(ing2);

            facade = new Facade();
            Dish dish = new Dish()
            {
                Description = "asd",
                Ingredients = list,
                Name = "dish1",
                Status = 0
            };
            dish = facade.DishRepo().Add(dish);
            facade = new Facade();

            dish.Name = "changed";
            dish.Description = "new descrip";
            dish.Status = 3;
            Ingredient ing3 = new Ingredient()
            {
                Name = "ing2",
                Price = 200
            };
            ing3 = facade.IngredientRepo().Add(ing3);
            dish.Ingredients.Add(ing3);

            facade.DishRepo().Update(dish);

            Assert.IsTrue(dish.Equals(facade.DishRepo().Get(dish.Id)));
        }
        public void Dish_update_updates_removed_ingredients_test()
        {
            Facade facade = new Facade();
            Ingredient ing = new Ingredient()
            {
                Name = "ing1",
                Price = 200
            };
            Ingredient ing2 = new Ingredient()
            {
                Name = "ing2",
                Price = 200
            };
            ing = facade.IngredientRepo().Add(ing);
            ing2 = facade.IngredientRepo().Add(ing2);

            List<Ingredient> list = new List<Ingredient>();
            list.Add(ing);
            list.Add(ing2);

            facade = new Facade();
            Dish dish = new Dish()
            {
                Description = "asd",
                Ingredients = list,
                Name = "dish1",
                Status = 0
            };
            dish = facade.DishRepo().Add(dish);

            facade = new Facade();
            dish.Ingredients.Remove(ing);

            Assert.IsTrue(facade.DishRepo().Update(dish));

            Assert.AreEqual(facade.DishRepo().Get(dish.Id).Ingredients.Count, 1, "the amount of ingredients is not right");
            Assert.IsNotNull(facade.IngredientRepo().Get(ing.Id), "Ingredient is removed from db");
        }
        public void Menu_same_dish_on_multiple_menu_test()
        {
            Facade facade = new Facade();

            Ingredient ing1 = new Ingredient() { Name = "ing1", Price = 10 };
            Ingredient ing2 = new Ingredient() { Name = "ing2", Price = 12 };
            Ingredient ing3 = new Ingredient() { Name = "ing3", Price = 13 };
            Ingredient ing4 = new Ingredient() { Name = "ing4", Price = 15 };

            ing1 = facade.IngredientRepo().Add(ing1);
            ing2 = facade.IngredientRepo().Add(ing2);
            ing3 = facade.IngredientRepo().Add(ing3);
            ing4 = facade.IngredientRepo().Add(ing4);

            Dish dish1 = new Dish() { Description = "descrip 1", Name = "dish1", Status = 0, Ingredients = new List<Ingredient>() { ing1, ing2 } };
            Dish dish2 = new Dish() { Description = "descrip 2", Name = "dish2", Status = 1, Ingredients = new List<Ingredient>() { ing3, ing4 } };
            Dish dish3 = new Dish() { Description = "descrip 3", Name = "dish3", Status = 3, Ingredients = new List<Ingredient>() { ing1, ing2, ing3, ing4 } };

            dish1 = facade.DishRepo().Add(dish1);
            dish2 = facade.DishRepo().Add(dish2);
            dish3 = facade.DishRepo().Add(dish3);

            Menu menu = new Menu() { Dishes = new List<Dish> { dish1, dish2, dish3 }, Name = "menu1" };
            Menu menu2 = new Menu() { Dishes = new List<Dish> { dish1, dish3 }, Name = "menu2" };
            menu = facade.MenuRepo().Add(menu);
            menu2 = facade.MenuRepo().Add(menu2);

            Assert.Contains(dish1, menu.Dishes);
            Assert.Contains(dish1, menu2.Dishes);
        }
        public void Ingredient_updates_returns_true_and_works_test()
        {
            Facade facade = new Facade();
            Ingredient ing = new Ingredient()
            {
                Name = "hestkød",
                Price = 200
            };
            ing =facade.IngredientRepo().Add(ing);

            facade = new Facade();
            ing.Name = "Changed";

            Assert.IsTrue(facade.IngredientRepo().Update(ing));
            Assert.AreEqual(facade.IngredientRepo().Get(ing.Id).Name, ing.Name);
        }
 public void Ingredient_update_returns_false_on_not_exsisting_test()
 {
     Facade facade = new Facade();
     Ingredient ing = new Ingredient()
     {
         Name = "hestkød",
         Price = 200
     };
     Assert.IsFalse(facade.IngredientRepo().Update(ing));
 }
        public void Dish_removing_dish_does_not_remove_ingredient_test()
        {
            Facade facade = new Facade();
            Ingredient ing = new Ingredient()
            {
                Name = "ing1",
                Price = 200
            };
            ing = facade.IngredientRepo().Add(ing);
            List<Ingredient> list = new List<Ingredient>();
            list.Add(ing);

            facade = new Facade();
            Dish dish = new Dish()
            {
                Description = "asd",
                Ingredients = list,
                Name = "dish1",
                Status = 0
            };
            dish = facade.DishRepo().Add(dish);
            facade = new Facade();

            facade.DishRepo().Remove(dish.Id);

            facade = new Facade();
            Assert.IsNotNull(facade.IngredientRepo().Get(ing.Id));
        }