public IQueryable<ProductReview> GetReviews()
        {
            IList<Product> products = GetProducts().ToList();
            IList<ProductReview> productReviews = new List<ProductReview>();
            int reviewID = 1;

            foreach (Product product in products)
            {
                for (int i = 0; i < 5; i++)
                {
                    ProductReview productReview = new ProductReview
                    {
                        Author = "minhajuddin",
                        Body = "This is a product review",
                        CreatedOn = DateTime.Now,
                        Email = "[email protected]",
                        ProductID = product.ID,
                        ID = reviewID
                    };

                    productReviews.Add(productReview);
                    reviewID++;
                }
            }

            return productReviews.AsQueryable();
        }
Example #2
0
 public void Review_Should_Have_ProductID_Author_Email_Body_CreatedOn_Fields()
 {
     ProductReview review = new ProductReview("minhajuddin", "[email protected]", 3, "Nice product");
     Assert.AreEqual("minhajuddin", review.Author, "the author of the product review isn't setup correctly");
     Assert.AreEqual("[email protected]", review.Email, "the email of the product review isn't setup correctly");
     Assert.AreEqual(3, review.ProductID, "the product id of the product review isn't setup correctly");
     Assert.AreEqual("Nice product", review.Body, "the body of the product review isn't setup correctly");
     Assert.AreEqual(DateTime.Now.Date, review.CreatedOn.Date, "the date of the product review isn't setup correctly");
 }