Exemplo n.º 1
0
        public void GetLocationsOfProductShouldWork()
        {
            Product prod = new Product {
                ProductName = "testprod", ProductPrice = 1
            };

            using (var ctx = new StoreContext(options))
            {
                StoreRepoDB repo = new StoreRepoDB(ctx);
                ctx.Products.Add(prod);
                ctx.SaveChanges();
                for (int i = 0; i < 5; i++)
                {
                    Location loc = new Location {
                        LocationName = $"testloc{i}", LocationAddress = "asdf"
                    };
                    ctx.Locations.Add(loc);
                    ctx.SaveChanges();
                    Inventory inv = new Inventory {
                        ProductId = prod.ProductId, LocationId = loc.LocationId, Quantity = i + 1
                    };
                    ctx.Inventories.Add(inv);
                }
                ctx.SaveChanges();
            }
            using (var assertCtx = new StoreContext(options))
            {
                StoreRepoDB repo        = new StoreRepoDB(assertCtx);
                var         inventories = repo.GetLocationsOfProduct(prod.ProductId, location => true);
                Assert.NotNull(inventories);
                Assert.Equal(5, inventories.Count);
            }
        }
Exemplo n.º 2
0
 public List <Inventory> GetLocationsOfProduct(int productId)
 {
     return(repo.GetLocationsOfProduct(productId, loc => true));
 }