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_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 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 Dish_add_using_new_ingredient_throws_exception_test() { Facade facade = new Facade(); Dish dish = new Dish() { Description = "asd", Name = "asd", Status = 1, Ingredients = new List<Ingredient>() { new Ingredient() { Name = "123", Price = 123 } } }; facade.DishRepo().Add(dish); }
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 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_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 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 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 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)); }
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 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 Dish_update_throws_exception_on_null_test() { Facade facade = new Facade(); facade.DishRepo().Update(null); }
public void Dish_update_returns_false_on_non_existing_dish_test() { Facade facade = new Facade(); Assert.IsFalse(facade.DishRepo().Update(new Dish())); }
public void Dish_add_throws_exception_on_null_test() { Facade facade = new Facade(); facade.DishRepo().Add(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_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_remove_throws_exception_on_null_test() { Facade facade = new Facade(); facade.DishRepo().Remove(-1); }