public static void Main() { //get the configuration from file var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); var optionsBuilder = new DbContextOptionsBuilder <Project1Context>(); optionsBuilder.UseSqlServer(configuration.GetConnectionString("Project1")); var repo = new PizzaRepos(new Project1Context(optionsBuilder.Options)); repo.UpdateLocationInventory(Order.OrderLocation, Order.OrderSize, Order.OrderToppings, Order.OrderQuantity); int custId = repo.CheckCustomerId(Customers.CustomerName); int locationId = repo.LookupLocationId(Order.OrderLocation); int pizzaId = repo.LookupPizzaId(Order.OrderSize, Order.OrderCrust); repo.AddPizzaOrder(custId, locationId, pizzaId, Order.OrderQuantity, Order.OrderCost, Order.OrderTime); repo.AddPizzaOrderToppings(Order.OrderToppings); repo.SaveChanges(); }
public void TestPizzaLookup() { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: true, reloadOnChange: true); IConfigurationRoot configuration = builder.Build(); //Console.WriteLine(configuration.GetConnectionString("Project1")); var optionsBuilder = new DbContextOptionsBuilder <Project1Context>(); optionsBuilder.UseSqlServer(configuration.GetConnectionString("Project1")); var repo = new PizzaRepos(new Project1Context(optionsBuilder.Options)); string size = "Small"; string crust = "Hand Tossed"; int low = 1; int high = 9; Assert.InRange(repo.LookupPizzaId(size, crust), low, high); }