public IQueryable<Product> GetProducts() { IList<Product> result = new List<Product>(); //Populate a few products for each category int loopIndex = 0; int uniqueProductID = 1; var categories = GetCategories().Where(x => x.ParentID > 0).ToList(); foreach (var category in categories) { for (int i = 1; i <= 5; i++) { Product p = new Product { Name = "Product" + loopIndex, ID = uniqueProductID, Price = i * 5.3M, Description = "Test product's description", CategoryID = category.ID }; uniqueProductID++; loopIndex++; result.Add(p); } } return result.AsQueryable(); }
public void Product_Should_Have_Name_Description_Price_Category_Discount_Fields() { Product p = new Product("TestName", "This is a test product", 100, 22.50M, 20); Assert.AreEqual("TestName", p.Name, "the product name is wrong"); Assert.AreEqual("This is a test product", p.Description, "the product description is wrong"); Assert.AreEqual(22.50M, p.Price, "the price is wrong"); Assert.AreEqual(20, p.DiscountPercent, "the discount percent is wrong"); Assert.AreEqual(100, p.CategoryID, "the category id is wrong"); }