public void GetPendingOrders() { var builder = new DbContextOptionsBuilder<UnicornStoreContext>(); builder.UseInMemoryDatabase(persist: true); var options = builder.Options; using (var context = new UnicornStoreContext(options)) { var orders = new List<Order> { new Order { State = OrderState.CheckingOut, ShippingDetails = new OrderShippingDetails() }, new Order { State = OrderState.Placed, ShippingDetails = new OrderShippingDetails() }, new Order { State = OrderState.Filling, ShippingDetails = new OrderShippingDetails() }, new Order { State = OrderState.ReadyToShip, ShippingDetails = new OrderShippingDetails() }, new Order { State = OrderState.Shipped, ShippingDetails = new OrderShippingDetails() }, new Order { State = OrderState.Delivered, ShippingDetails = new OrderShippingDetails() }, new Order { State = OrderState.Cancelled, ShippingDetails = new OrderShippingDetails() }, }; context.AddRange(orders); context.AddRange(orders.Select(o => o.ShippingDetails)); context.SaveChanges(); } using (var context = new UnicornStoreContext(options)) { var controller = new ShippingController(context); var orders = controller.PendingOrders(); Assert.Equal(1, orders.Count()); } }
public OrdersController(UnicornStoreContext context) { db = context; }
public ShippingController(UnicornStoreContext context) { db = context; }
public CategoryCache(UnicornStoreContext context) { byKey = new Lazy<Dictionary<int, Category>>(() => context.Categories.ToDictionary(c => c.CategoryId)); topLevel = new Lazy<Category[]>(() => byKey.Value.Values.Where(c => c.ParentCategoryId == null).ToArray()); }
public ManageProductsController(UnicornStoreContext context, CategoryCache cache) { db = context; categoryCache = cache; }
public CartController(UnicornStoreContext context, ApplicationDbContext identityContext, CategoryCache cache) { db = context; identityDb = identityContext; categoryCache = cache; }
public HomeController(UnicornStoreContext context, CategoryCache cache) { db = context; categoryCache = cache; }
public CategoryCache(UnicornStoreContext context) { byKey = new Lazy <Dictionary <int, Category> >(() => context.Categories.ToDictionary(c => c.CategoryId)); topLevel = new Lazy <Category[]>(() => byKey.Value.Values.Where(c => c.ParentCategoryId == null).ToArray()); }
public RecallsController(UnicornStoreContext context) { db = context; }