public void ToEntityPizzaTemplate_NameIsNull_PizzaTemplateDtoIsEqualToPizzaTemplate() { TemplateDto expected = new TemplateDto( "Template", 700, "ImageUrl.png", new List <IngredientDto>()); expected.Ingredients.Add(new IngredientDto( "Dough", 200, "Dough.png", "DoughBase.png", new CategoryDto(Categories.Dough.ToString()), 5)); expected.Ingredients.Add(new IngredientDto( "Bacon", 200, "Bacon.png", "BaconBase.png", new CategoryDto(Categories.Meat.ToString()), 50)); PizzaTemplate actual = EntityBuilder.ToEntity(expected); base.AssertPizzaTemplatesAreEqual(actual, expected); }
public void ToPizzaTemplateDto_NameIsNull_PizzaTemplateDtoIsEqualToPizzaTemplate() { PizzaTemplate expected = new PizzaTemplate( Guid.NewGuid(), null, "ImageUrl.png", 700); expected.Ingredients.Add(new Ingredient( Guid.NewGuid(), "Dough", 200, "Dough.png", "DoughBase.png", Categories.Dough, 5)); expected.Ingredients.Add(new Ingredient( Guid.NewGuid(), "Bacon", 200, "Bacon.png", "BaconBase.png", Categories.Meat, 50)); TemplateDto actual = DtoBuilder.ToDto(expected); base.AssertPizzaTemplatesAreEqual(expected, actual); }
public void ToEntityPizzaTemplate_PizzaTemplateIsEmpty_PizzaTemplateDtoIsEqualToPizzaTemplate() { TemplateDto expected = new TemplateDto(); PizzaTemplate actual = EntityBuilder.ToEntity(expected); base.AssertPizzaTemplatesAreEqual(actual, expected); }
public void ToPizzaTemplateDto_PizzaTemplateIsEmpty_PizzaTemplateDtoIsEqualToPizzaTemplate() { PizzaTemplate expected = new PizzaTemplate(); TemplateDto actual = DtoBuilder.ToDto(expected); base.AssertPizzaTemplatesAreEqual(expected, actual); }
public static TemplateDto ToDto(PizzaTemplate pizzaTemplate) { TemplateDto templateDto = new TemplateDto(pizzaTemplate.Name, pizzaTemplate.TotalCost, pizzaTemplate.ImageUrl, new List <IngredientDto>()); foreach (var ingredient in pizzaTemplate.Ingredients) { templateDto.Ingredients.Add(ToDto(ingredient)); } return(templateDto); }
public void ToEntityPizzaTemplate_IngredientsAreNull_NullReferenceException() { TemplateDto expected = new TemplateDto( "Template", 700, "ImageUrl.png", new List <IngredientDto>()); expected.Ingredients = null; PizzaTemplate actual = EntityBuilder.ToEntity(expected); }
public void ToPizzaTemplateDto_IngredientsAreNull_NullReferenceException() { PizzaTemplate expected = new PizzaTemplate( Guid.NewGuid(), "Template", "ImageUrl.png", 700); expected.Ingredients = null; TemplateDto actual = DtoBuilder.ToDto(expected); }
public static PizzaTemplate ToEntity(TemplateDto templateDto) { var pizzaTemplate = new PizzaTemplate(Guid.NewGuid(), templateDto.Name, templateDto.ImageUrl, templateDto.TotalCost); foreach (var ingredientDto in templateDto.Ingredients) { pizzaTemplate.Ingredients.Add(ToEntity(ingredientDto)); } return(pizzaTemplate); }
public void ToEntityPizzaTemplate_IngredientsAreEmpty_PizzaTemplateDtoIsEqualToPizzaTemplate() { TemplateDto expected = new TemplateDto( "Template", 700, "ImageUrl.png", new List <IngredientDto>()); expected.Ingredients = new List <IngredientDto>(); PizzaTemplate actual = EntityBuilder.ToEntity(expected); base.AssertPizzaTemplatesAreEqual(actual, expected); }
public void ToPizzaTemplateDto_IngredientsAreEmpty_PizzaTemplateDtoIsEqualToPizzaTemplate() { PizzaTemplate expected = new PizzaTemplate( Guid.NewGuid(), "Template", "ImageUrl.png", 700); expected.Ingredients = new List <Ingredient>(); TemplateDto actual = DtoBuilder.ToDto(expected); base.AssertPizzaTemplatesAreEqual(expected, actual); }
protected void AssertPizzaTemplatesAreEqual(PizzaTemplate pizzaTemplate, TemplateDto templateDto) { Assert.AreEqual(pizzaTemplate.Name, templateDto.Name); Assert.AreEqual(pizzaTemplate.TotalCost, templateDto.TotalCost); Assert.AreEqual(pizzaTemplate.Ingredients.Count, templateDto.Ingredients.Count); for (int i = 0; i < pizzaTemplate.Ingredients.Count; i++) { Ingredient expectedIngredient = pizzaTemplate.Ingredients.ElementAt(i); IngredientDto actualIngredientDto = templateDto.Ingredients.ElementAt(i); this.AssertIngredientsAreEqual(expectedIngredient, actualIngredientDto); } }
protected override void Seed(PizzaDataContext context) { User u1 = new User("Oleksandr Yatsenko", "*****@*****.**"); Contact c1 = new Contact(Guid.NewGuid(), "John1", "000000", "USA"); Ingredient i1 = new Ingredient(Guid.NewGuid(), "Tomato", 5, "/Content/Images/Layers/TomatoLayer.png", "/Content/Images/Tomato.png", Categories.Vegetables, 30); Ingredient i2 = new Ingredient(Guid.NewGuid(), "Pickle", 6, "/Content/Images/Layers/PickleLayer.png", "/Content/Images/Pickle.png", Categories.Vegetables, 30); Ingredient i3 = new Ingredient(Guid.NewGuid(), "Onion", 2, "/Content/Images/Layers/OnionLayer.png", "/Content/Images/Onion.png", Categories.Vegetables, 30); Ingredient i4 = new Ingredient(Guid.NewGuid(), "Mushroom", 8, "/Content/Images/Layers/MushroomLayer.png", "/Content/Images/Mushroom.png", Categories.Vegetables, 30); Ingredient i5 = new Ingredient(Guid.NewGuid(), "Olivas-Black", 4, "/Content/Images/Layers/BlackOlivaLayer.png", "/Content/Images/Olivas-Black.png", Categories.Vegetables, 30); Ingredient i6 = new Ingredient(Guid.NewGuid(), "Olivas-Green", 4, "/Content/Images/Layers/GreenOlivaLayer.png", "/Content/Images/Olivas-Green.png", Categories.Vegetables, 30); Ingredient i7 = new Ingredient(Guid.NewGuid(), "Cheader", 6, "/Content/Images/Layers/ChedderLayer.png", "/Content/Images/Cheader.png", Categories.Cheese, 20); Ingredient i8 = new Ingredient(Guid.NewGuid(), "Mozzarella", 6, "/Content/Images/Layers/MozarellaLayer.png", "/Content/Images/Mozzarella.png", Categories.Cheese, 20); Ingredient i9 = new Ingredient(Guid.NewGuid(), "Pepperoni", 14, "/Content/Images/Layers/PepperoniLayer.png", "/Content/Images/Pepperoni.png", Categories.Meat, 40); Ingredient i10 = new Ingredient(Guid.NewGuid(), "Chicken", 12, "/Content/Images/Layers/ChickenLayer.png", "/Content/Images/Chicken.png", Categories.Meat, 40); Ingredient i11 = new Ingredient(Guid.NewGuid(), "Salami", 15, "/Content/Images/Layers/SalamiLayer.png", "/Content/Images/Salami.png", Categories.Meat, 40); Ingredient i12 = new Ingredient(Guid.NewGuid(), "Bacon", 15, "/Content/Images/Layers/BaconLayer.png", "/Content/Images/Bacon.png", Categories.Meat, 40); Ingredient i13 = new Ingredient(Guid.NewGuid(), "Shrimp", 20, "/Content/Images/Layers/SrimpLayer.png", "/Content/Images/Shrimp.png", Categories.SeaFood, 50); Ingredient i14 = new Ingredient(Guid.NewGuid(), "Cetchup", 1, "/Content/Images/Layers/SouseLayer.png", "/Content/Images/Cetchup.png", Categories.Souses, 10); Ingredient i15 = new Ingredient(Guid.NewGuid(), "Dough", 10, "/Content/Images/Layers/DoughLayer.png", "/Content/Images/Dough.png", Categories.Dough, 5); Ingredient i16 = new Ingredient(Guid.NewGuid(), "Pineapple", 6, "/Content/Images/Layers/PineappleLayer.png", "/Content/Images/Pineapple.png", Categories.Vegetables, 30); PizzaTemplate p2 = new PizzaTemplate(Guid.NewGuid(), "Margarita Template", "URL here", 27); p2.Ingredients.Add(i7); p2.Ingredients.Add(i1); p2.Ingredients.Add(i2); p2.Ingredients.Add(i15); PizzaTemplate p3 = new PizzaTemplate(Guid.NewGuid(), "Meat Bomb Template", string.Empty, 35); p3.Ingredients.Add(i8); p3.Ingredients.Add(i5); p3.Ingredients.Add(i4); p3.Ingredients.Add(i3); p3.Ingredients.Add(i1); p3.Ingredients.Add(i15); PizzaTemplate p4 = new PizzaTemplate(Guid.NewGuid(), "Vegan Dream", string.Empty, 33); p4.Ingredients.Add(i7); p4.Ingredients.Add(i6); p4.Ingredients.Add(i2); p4.Ingredients.Add(i1); p4.Ingredients.Add(i15); context.Ingredients.Add(i1); context.Ingredients.Add(i2); context.Ingredients.Add(i3); context.Ingredients.Add(i4); context.Ingredients.Add(i5); context.Ingredients.Add(i6); context.Ingredients.Add(i7); context.Ingredients.Add(i8); context.Ingredients.Add(i9); context.Ingredients.Add(i10); context.Ingredients.Add(i11); context.Ingredients.Add(i12); context.Ingredients.Add(i13); context.Ingredients.Add(i14); context.Ingredients.Add(i15); context.Ingredients.Add(i16); context.Templates.Add(p2); context.Templates.Add(p3); context.Templates.Add(p4); context.Users.Add(u1); context.Contacts.Add(c1); base.Seed(context); }