public void InventoryAccessor_GetOrdersByCustomerId_ShouldSucceed() { // Arrange using var inventoryDbContext = InventoryDbContext; try { // Insert seed data into the database using one instance of the context AddCustomers(inventoryDbContext); AddOrders(inventoryDbContext); var inventoryAccessor = new InventoryAccessor(inventoryDbContext, Mapper); // Act var orders = inventoryAccessor.GetOrdersByCustomerId(1); // Assert Assert.True(orders.Any()); Assert.Equal(2, orders.Count); } finally { inventoryDbContext.ChangeTracker .Entries() .ToList() .ForEach(e => e.State = EntityState.Detached); inventoryDbContext.Database.EnsureDeleted(); } }
public List <Contracts.Order> GetOrdersByCustomerId(int customerId) { var orders = InventoryAccessor.GetOrdersByCustomerId(customerId); return(Mapper.Map <List <Contracts.Order> >(orders)); }