public Domain.Abstracts.ACrust Map(Entities.Crust model) { Domain.Abstracts.ACrust crust = null; switch (model.CrustType) { case CRUST_TYPE.CheeseStuffed: crust = new CheeseStuffedCrust(); break; case CRUST_TYPE.DeepDish: crust = new DeepDishCrust(); break; case CRUST_TYPE.Traditional: crust = new TraditionalCrust(); break; case CRUST_TYPE.Unknown: // TODO: add logging to these last 2 default: throw new ArgumentException("CrustMapper ran into an unknown Crust Type when mapping from DB Model to Domain Model"); } crust.Price = model.Price; crust.ID = model.ID; crust.Name = model.Name; crust.CrustType = model.CrustType; // not really needed return(crust); }
public void Test_DeepDishCrustPrice() { // arrange var sut = new DeepDishCrust(); // act var actual = sut.Price; // assert Assert.Equal(actual, 1.5m); }
public void Test_DeepDishCrustName() { // arrange var sut = new DeepDishCrust(); // act var actual = sut.Name; // assert Assert.Equal(actual, "Deep Dish Crust"); }
public void Test_CrustMapping() { // arrange MapperCrust mapperCrust = new MapperCrust(); var sut = new DeepDishCrust(); // act var sut2 = mapperCrust.Map(sut); var actual = sut2.CRUST; // assert Assert.True(actual == CRUSTS.DEEPDISH); }
public ActionResult <APizza> GetPizzaInfo(PIZZAS PIZZA, SIZES SIZE, CRUSTS CRUST, [FromQuery] List <TOPPINGS> TOPPING) { APizza pizza; ASize size; ACrust crust; List <ATopping> toppings = new List <ATopping>(); switch (SIZE) { case SIZES.SMALL: size = new SmallSize(); break; case SIZES.MEDIUM: size = new MediumSize(); break; case SIZES.LARGE: size = new LargeSize(); break; default: return(StatusCode(400, "Size not recognized")); } switch (CRUST) { case CRUSTS.DEEPDISH: crust = new DeepDishCrust(); break; case CRUSTS.STANDARD: crust = new StandardCrust(); break; case CRUSTS.STUFFED: crust = new StuffedCrust(); break; case CRUSTS.THIN: crust = new ThinCrust(); break; default: return(StatusCode(400, "Crust not recognized")); } foreach (TOPPINGS toppingEnum in TOPPING) { switch (toppingEnum) { case TOPPINGS.BACON: toppings.Add(new Bacon()); break; case TOPPINGS.CHICKEN: toppings.Add(new Chicken()); break; case TOPPINGS.EXTRACHEESE: toppings.Add(new ExtraCheese()); break; case TOPPINGS.GREENPEPPER: toppings.Add(new GreenPepper()); break; case TOPPINGS.HAM: toppings.Add(new Ham()); break; case TOPPINGS.NOCHEESE: toppings.Add(new NoCheese()); break; case TOPPINGS.PINEAPPLE: toppings.Add(new Pineapple()); break; case TOPPINGS.REDPEPPER: toppings.Add(new RedPepper()); break; case TOPPINGS.SAUSAGE: toppings.Add(new Sausage()); break; default: return(StatusCode(400, "Topping not recognized")); } } pizza = new APizza { PIZZA = PIZZA, Name = Enum.GetName <PIZZAS>(PIZZA), Crust = crust, Toppings = toppings }; switch (PIZZA) { case PIZZAS.MEAT: pizza = new MeatPizza(size); pizza.Crust = crust; pizza.Toppings = toppings; break; case PIZZAS.HAWAIIAN: pizza = new HawaiianPizza(size); pizza.Crust = crust; pizza.Toppings = toppings; break; case PIZZAS.VEGAN: pizza = new VeganPizza(size); pizza.Crust = crust; pizza.Toppings = toppings; break; case PIZZAS.CUSTOM: pizza = new CustomPizza(crust, size, toppings); break; default: return(StatusCode(400, "Size not recognized")); } pizza.CalculatePrice(); return(Ok(pizza)); }
public override void AddCrust() { Crust = new DeepDishCrust(); }