public void GetProductByIdShouldGetCorrectProduct()
 {
     using (var ctx = new StoreContext(options))
     {
         StoreRepoDB repo    = new StoreRepoDB(ctx);
         var         product = repo.GetProductById(3);
         Assert.Null(product);
         for (int i = 0; i < 5; i++)
         {
             Product testProduct = new Product();
             testProduct.ProductName  = $"Test{i}";
             testProduct.ProductPrice = i;
             ctx.Products.Add(testProduct);
         }
         ctx.SaveChanges();
     }
     using (var assertCtx = new StoreContext(options))
     {
         StoreRepoDB repo    = new StoreRepoDB(assertCtx);
         var         product = repo.GetProductById(3);
         Assert.NotNull(product);
         Assert.Equal(3, product.ProductId);
     }
 }
Esempio n. 2
0
 public Product GetProductById(int id)
 {
     return(repo.GetProductById(id));
 }