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 Address_get_returns_all_values_correctly_test() { Facade facade = new Facade(); Address add = new Address() { Country = "asd", StreetAddress = "asd", ZipCode = "1234" }; add = facade.AddressRepo().Add(add); facade = new Facade(); Assert.AreEqual(facade.AddressRepo().Get(add.Id).Country, add.Country); Assert.AreEqual(facade.AddressRepo().Get(add.Id).StreetAddress, add.StreetAddress); Assert.AreEqual(facade.AddressRepo().Get(add.Id).ZipCode, add.ZipCode); }
public void Address_getall_returns_multiple_test() { Facade facade = new Facade(); Address add = new Address() { Country = "asd", StreetAddress = "asd", ZipCode = "1234" }; add = facade.AddressRepo().Add(add); facade.AddressRepo().Add(add); add = facade.AddressRepo().Add(add); facade = new Facade(); Assert.GreaterOrEqual(facade.AddressRepo().GetAll().ToList().Count, 2); }
public void Address_adds_on_call_test() { Facade facade = new Facade(); Address add = new Address() { Country = "asd", StreetAddress = "asd", ZipCode ="1234" }; add = facade.AddressRepo().Add(add); facade = new Facade(); Assert.AreEqual(facade.AddressRepo().Get(add.Id).Country, add.Country); }
public void Customer_add_throws_exception_on_updated_customer_test() { Facade facade = new Facade(); Address address = new Address() { Country = "Denmark", StreetAddress = "Møbelvej 3", ZipCode = "6800" }; address = facade.AddressRepo().Add(address); address.StreetAddress = "changed"; Customer cus = new Customer() { Address = address, Email = "*****@*****.**", FirstName = "Jonas", LastName = "Olesen", PhoneNumber = "22342312" }; cus = facade.CustomerRepo().Add(cus); }
public Customer MakeCustomer() { Facade facade = new Facade(); Address address = new Address() { Country = "Denmark", StreetAddress = "Møbelvej 3", ZipCode = "6800" }; address = facade.AddressRepo().Add(address); Customer cus = new Customer() { Address = address, Email = "*****@*****.**", FirstName = "Jonas", LastName = "Olesen", PhoneNumber = "22342312" }; cus = facade.CustomerRepo().Add(cus); return cus; }
public void Customer_update_updates_address_test() { Facade facade = new Facade(); Customer cus = MakeCustomer(); Address address = new Address() { Country = "Denmark2", StreetAddress = "Møbelvej 32", ZipCode = "68002" }; address = facade.AddressRepo().Add(address); cus.Address = address; facade.CustomerRepo().Update(cus); Assert.IsTrue(address.Equals(facade.CustomerRepo().Get(cus.Id).Address)); }
public void Customer_remove_does_not_remove_address_test() { Customer cus = MakeCustomer(); Facade facade = new Facade(); facade.CustomerRepo().Remove(cus.Id); Assert.IsNotNull(facade.AddressRepo().Get(cus.Address.Id)); }
public void Address_remove_throws_new_exception_on_null_test() { Facade facade = new Facade(); facade.AddressRepo().Remove(-1); }
public void Address_remove_removes_right_one_test() { Facade facade = new Facade(); Address add = new Address() { Country = "asd", StreetAddress = "asd", ZipCode = "1234" }; add = facade.AddressRepo().Add(add); facade = new Facade(); facade.AddressRepo().Remove(add.Id); facade = new Facade(); Assert.IsNull(facade.AddressRepo().Get(add.Id)); }
public void Address_add_throws_exception_on_item_equals_null_test() { Facade facade = new Facade(); facade.AddressRepo().Add(null); }
public void Address_update_throws_exception_on_null_test() { Facade facade = new Facade(); facade.AddressRepo().Update(null); }
public void Address_update_returns_false_on_not_exsisting_test() { Facade facade = new Facade(); Address add = new Address() { Country = "asd", StreetAddress = "asd", ZipCode = "1234" }; Assert.IsFalse(facade.AddressRepo().Update(add)); }
public void Address_updates_returns_true_and_works_test() { Facade facade = new Facade(); Address add = new Address() { Country = "asd", StreetAddress = "asd", ZipCode = "1234" }; add = facade.AddressRepo().Add(add); facade = new Facade(); add.Country = "Changed"; Assert.IsTrue(facade.AddressRepo().Update(add)); Assert.AreEqual(facade.AddressRepo().Get(add.Id).Country, add.Country); }
public void Party_update_new_customer_and_address_test() { Facade facade = new Facade(); Party par = MakeParty(); Address address = new Address() { Country = "Esbjerg", StreetAddress = "fisk 3", ZipCode = "6800" }; address = facade.AddressRepo().Add(address); par.Address = address; Customer cus = new Customer() { Address = address, Email = "*****@*****.**", FirstName = "Jonas", LastName = "Olesen", PhoneNumber = "22342312" }; cus = facade.CustomerRepo().Add(cus); par.Customer = cus; facade.PartyRepo().Update(par); Assert.IsTrue(par.Customer.Equals( facade.PartyRepo().Get(par.Id).Customer)); Assert.IsTrue(par.Address.Equals( facade.PartyRepo().Get(par.Id).Address)); }
public void Customer_add_uses_existing_customer_test() { Facade facade = new Facade(); Address address = new Address() { Country = "Denmark", StreetAddress = "Møbelvej 3", ZipCode = "6800" }; address = facade.AddressRepo().Add(address); Customer cus = new Customer() { Address = address, Email = "*****@*****.**", FirstName = "Jonas", LastName = "Olesen", PhoneNumber = "22342312" }; cus = facade.CustomerRepo().Add(cus); Assert.IsTrue(facade.CustomerRepo().Get(cus.Id).Address.Equals(address)); }
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)); }