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 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 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 Menu_add_throws_exception_on_null_dish_test()
 {
     Facade facade = new Facade();
     facade.MenuRepo().Add(null);
 }
 public void Menu_update_updates_removed_child_test()
 {
     Menu menu = MakeMenu();
     Facade facade = new Facade();
     int dishes = menu.Dishes.Count;
     menu.Dishes.Remove(menu.Dishes.FirstOrDefault());
     facade.MenuRepo().Update(menu);
     Assert.AreEqual(dishes-1, facade.MenuRepo().Get(menu.Id).Dishes.Count);
 }
 public void Menu_update_updates_properties_test()
 {
     Menu menu = MakeMenu();
     Facade facade = new Facade();
     menu.Name = "changed";
     facade.MenuRepo().Update(menu);
     Assert.IsTrue(menu.Equals(facade.MenuRepo().Get(menu.Id)));
 }
 public void Menu_update_updates_added_child_test()
 {
     Menu menu = MakeMenu();
     Facade facade = new Facade();
     Dish dish = new Dish() { Description = "asd", Name = "asd", Status = 2 };
     dish = facade.DishRepo().Add(dish);
     menu.Dishes.Add(dish);
     facade.MenuRepo().Update(menu);
     Assert.IsTrue(facade.MenuRepo().Get(menu.Id).Dishes.Any(x => x.Id == dish.Id));
 }
 public void Menu_update_throws_exception_on_updated_dish_test()
 {
     Menu menu = MakeMenu();
     Facade facade = new Facade();
     menu.Dishes.FirstOrDefault().Name = "changed";
     facade.MenuRepo().Update(menu);
 }
 public void Menu_update_throws_exception_on_null_test()
 {
     Facade facade = new Facade();
     facade.MenuRepo().Update(null);
 }
 public void Menu_update_throws_exception_on_new_dish_test()
 {
     Menu menu = MakeMenu();
     Facade facade = new Facade();
     Dish dish = new Dish() { Description = "asd", Name = "asd", Status = 2 };
     menu.Dishes.Add(dish);
     facade.MenuRepo().Update(menu);
 }
 public void Menu_update_returns_false_on_non_existing_menu_test()
 {
     Facade facade = new Facade();
     Assert.IsFalse(facade.MenuRepo().Update(new Menu()));
 }
        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 Menu_remove_throws_exception_on_null_test()
 {
     Facade facade = new Facade();
     facade.MenuRepo().Remove(-1);
 }
 public void Menu_remove_does_not_remove_dish_test()
 {
     Menu menu = MakeMenu();
     Facade facade = new Facade();
     Dish dish = menu.Dishes.FirstOrDefault();
     facade.MenuRepo().Remove(menu.Id);
     Assert.IsNotNull(facade.DishRepo().Get(dish.Id));
 }
 public void Party_update_adds_new_children_test()
 {
     Party par = MakeParty();
     Facade facade = new Facade();
     Menu temp = new Menu() { Name = "temp", Dishes = new List<Dish>() { par.Menus.FirstOrDefault().Dishes.FirstOrDefault() } };
     temp = facade.MenuRepo().Add(temp);
     par.Menus.Add(temp);
     facade.PartyRepo().Update(par);
     Assert.IsTrue(facade.PartyRepo().Get(par.Id).Menus.Any(x => x.Id == temp.Id));
 }
 public void Menu_add_using_new_dish_throws_exception_test()
 {
     Facade facade = new Facade();
     Menu menu = new Menu() { Name = "menu", Dishes = new List<Dish>() { new Dish() } };
     facade.MenuRepo().Add(menu);
 }
 public void Menu_getall_includes_children_test()
 {
     Menu menu = MakeMenu();
     Facade facade = new Facade();
     Assert.IsNotEmpty(facade.MenuRepo().GetAll().FirstOrDefault(x=>  x.Id == menu.Id).Dishes, "Dishes are not loaded");
     Assert.IsNotEmpty(facade.MenuRepo().GetAll().FirstOrDefault(x => x.Id == menu.Id).Dishes.FirstOrDefault().Ingredients, "Ingredients are not loaded");
 }
 public void Party_remove_does_not_remove_children_test()
 {
     Party par = MakeParty();
     Facade facade = new Facade();
     facade.PartyRepo().Remove(par.Id);
     Assert.IsNotNull(facade.MenuRepo().Get(par.Menus.FirstOrDefault().Id));
     Assert.IsNotNull(facade.CustomerRepo().Get(par.Customer.Id));
     Assert.IsNotNull(facade.AddressRepo().Get(par.Address.Id));
 }