public void GetProductQuantityByIdTest_GivesIdToListWhichDoesntContainSpecifiedId_Returns0() { ProductLibrary library = new ProductLibrary(); List <Product> products = new List <Product>(); var product = new Product { Id = 1 }; products.Add(product); var result = library.GetProductQuantityById(2, products); Assert.AreEqual(result, 0); }
public void GetProductQuantityByIdTest_GivesId_ReturnsProductQuantityForSpecifiedId(int id, int q) { ProductLibrary library = new ProductLibrary(); List <Product> products = new List <Product>(); var product = new Product { Id = id, Quantity = q }; products.Add(product); products.Add(new Product { Id = 2, Quantity = 5 }); products.Add(new Product { Id = 9, Quantity = 1 }); var result = library.GetProductQuantityById(id, products); Assert.AreEqual(result, product.Quantity); }