public void InitTs(APizzaComponent apc) { //ItemType toppings = new ItemType("topping"); // AddTopping(0.75m, 100, "beef", apc); // AddTopping(1.50m, 100, "chicken", apc); // AddTopping(0.57m, 100, "ham", apc); // AddTopping(0.45m, 100, "mushroom", apc); // AddTopping(0.25m, 100, "olive", apc); // AddTopping(0.30m, 100, "peppers", apc); // AddTopping(0.50m, 100, "pineapple", apc); // AddTopping(0.70m, 100, "salami", apc); // AddTopping(0.70m, 100, "sausage", apc); // AddTopping(0.50m, 100, "bacon", apc); // AddTopping(1.00m, 100, "onion", apc); // AddTopping(0.25m, 100, "pepporoni", apc); AddTopping(0.75m, 100, apc); AddTopping(1.50m, 100, apc); AddTopping(0.57m, 100, apc); AddTopping(0.45m, 100, apc); AddTopping(0.25m, 100, apc); AddTopping(0.30m, 100, apc); AddTopping(0.50m, 100, apc); AddTopping(0.70m, 100, apc); AddTopping(0.70m, 100, apc); AddTopping(0.50m, 100, apc); AddTopping(1.00m, 100, apc); AddTopping(0.25m, 100, apc); }
public void Test_AddNewPizza() { var options = new DbContextOptionsBuilder <StoreContext>() .UseInMemoryDatabase(databaseName: "TestDb16") .Options; using (var context = new StoreContext(options)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); StoreRepository storeRepo = new StoreRepository(context); StoreLogic sl = new StoreLogic(storeRepo); AStore store = new AStore(); store.Name = "Store1"; ItemType item = new ItemType("toppings"); APizzaComponent testCrust = new APizzaComponent("testcrust", item); APizzaComponent testTopping = new APizzaComponent("testtopping", item); Crust tempCrust = new Crust(store, 0, 1, testCrust); Topping tempTopping = new Topping(store, 0, 1, testTopping); context.Add <AStore>(store); context.Add <ItemType>(item); context.Add <APizzaComponent>(testCrust); context.Add <APizzaComponent>(testTopping); context.Add <Crust>(tempCrust); context.Add <Topping>(tempTopping); context.SaveChanges(); RawComp rawCrust = new RawComp(); rawCrust.ID = tempCrust.CrustID; rawCrust.Inventory = 0; rawCrust.Name = "testcrust"; rawCrust.Price = 0; RawComp rawTopping = new RawComp(); rawTopping.ID = tempTopping.ToppingID; rawTopping.Inventory = 0; rawTopping.Name = "testtopping"; rawTopping.Price = 0; RawNewPizza rawTest = new RawNewPizza(); rawTest.ID = store.StoreID; rawTest.Name = "testpizza"; rawTest.Crust = rawCrust; rawTest.AllToppings = new List <RawComp>(); rawTest.AllToppings.Add(rawTopping); Assert.True(sl.AddNewPizza(rawTest)); } }
public void Test_CreateOrder() { var options = new DbContextOptionsBuilder <OrderContext>() .UseInMemoryDatabase(databaseName: "TestDb21") .Options; var options1 = new DbContextOptionsBuilder <StoreContext>() .UseInMemoryDatabase(databaseName: "TestDb21") .Options; var options2 = new DbContextOptionsBuilder <CustomerContext>() .UseInMemoryDatabase(databaseName: "TestDb21") .Options; using (var context = new OrderContext(options)) { using (var context1 = new StoreContext(options1)) { using (var context2 = new CustomerContext(options2)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); context1.Database.EnsureDeleted(); context1.Database.EnsureCreated(); context2.Database.EnsureDeleted(); context2.Database.EnsureCreated(); OrderRepository orderRepo = new OrderRepository(context); StoreRepository storeRepo = new StoreRepository(context1); CustomerRepository custRepo = new CustomerRepository(context2); OrderLogic ol = new OrderLogic(orderRepo, storeRepo, custRepo); AStore store = new AStore(); Customer newCust = new Customer(); ItemType item = new ItemType("toppings"); APizzaComponent testCrust = new APizzaComponent("testcrust", item); APizzaComponent testTopping = new APizzaComponent("testtopping", item); APizzaComponent testSize = new APizzaComponent("testsize", item); Crust tempCrust = new Crust(store, 0, 1, testCrust); Topping tempTopping = new Topping(store, 0, 1, testTopping); Size tempSize = new Size(store, 0, 1, testSize); context1.Add <AStore>(store); context2.Add <Customer>(newCust); context1.Add <ItemType>(item); context1.Add <APizzaComponent>(testCrust); context1.Add <APizzaComponent>(testTopping); context1.Add <APizzaComponent>(testSize); context1.Add <Crust>(tempCrust); context1.Add <Topping>(tempTopping); context1.Add <Size>(tempSize); context.SaveChanges(); context1.SaveChanges(); context2.SaveChanges(); RawPizza rawTest = new RawPizza(); rawTest.Name = "Test Pizza"; rawTest.Price = 0; rawTest.Crust = "testcrust"; rawTest.Size = "testsize"; rawTest.Toppings = new List <string>(); rawTest.Toppings.Add("testtopping"); RawOrder newOrder = new RawOrder(); newOrder.PizzaList = new List <RawPizza>(); newOrder.StoreID = store.StoreID; newOrder.CustomerID = newCust.CustomerID; newOrder.Total = 0; newOrder.PizzaList.Add(rawTest); Order createOrder = ol.CreateOrder(newOrder); Assert.NotNull(createOrder); } } } }