public void GetProduct_ShouldReturnProductWithSameId() { var context = new TestStoreAppContext(); context.Products.Add(GetDemoProduct()); var controller = new ProductController(context); var result = controller.GetProduct(3) as OkNegotiatedContentResult <Product>; Assert.IsNotNull(result); Assert.AreEqual(3, result.Content.Id); }
public void DeleteProduct_ShouldReturnOk() { var context = new TestStoreAppContext(); var item = GetDemoProduct(); context.Products.Add(item); var controller = new ProductController(context); var result = controller.DeleteProduct(3) as OkNegotiatedContentResult <Product>; Assert.IsNotNull(result); Assert.AreEqual(item.Id, result.Content.Id); }
public void GetProducts_ShouldReturnAllProducts() { var context = new TestStoreAppContext(); context.Products.Add(new Product { ID = 1, Name = "Demo1", Price = 20 }); context.Products.Add(new Product { ID = 2, Name = "Demo2", Price = 30 }); context.Products.Add(new Product { ID = 3, Name = "Demo3", Price = 40 }); var controller = new ProductController(context); var result = controller.GetProducts() as TestProductDbSet; Assert.IsNotNull(result); Assert.AreEqual(3, result.Local.Count); }