Esempio n. 1
0
        public void UpdateReviewTest()
        {
            AdventureWorksDataContext db  = new AdventureWorksDataContext();
            ProductService            pr  = new ProductService();
            ProductReviewService      prs = new ProductReviewService();

            Product product = new Product();

            product.Name          = "Test-Update-ProductReview2";
            product.ProductNumber = "Test-U-PR";

            pr.CreateProduct(product);

            ProductReview productReview = new ProductReview();

            productReview.Rating    = 1;
            productReview.Comments  = "Comments-Test";
            productReview.ProductID = product.ProductID;
            prs.CreateReview(productReview);

            productReview.Comments = "UPDATED-Comments-Test";
            prs.UpdateReview(productReview);

            ProductReview actualProductReview = (from p in db.ProductReview
                                                 where p.ProductID.Equals(product.ProductID)
                                                 select p).First();

            Assert.AreEqual("UPDATED-Comments-Test", actualProductReview.Comments);
            prs.DeleteReview(productReview);
            pr.DeleteProduct(product);
        }
Esempio n. 2
0
        public void GetAllReviewsByProductIdTest()
        {
            AdventureWorksDataContext db  = new AdventureWorksDataContext();
            ProductService            pr  = new ProductService();
            ProductReviewService      prs = new ProductReviewService();

            Product product = new Product();

            product.Name          = "Test-GetAll-ProductReview1";
            product.ProductNumber = "Test-GetAll-PR";

            pr.CreateProduct(product);

            ProductReview productReview1 = new ProductReview();

            productReview1.Rating    = 1;
            productReview1.Comments  = "Comments-Test1";
            productReview1.ProductID = product.ProductID;
            prs.CreateReview(productReview1);

            ProductReview productReview2 = new ProductReview();

            productReview2.Rating    = 2;
            productReview2.Comments  = "Comments-Test2";
            productReview2.ProductID = product.ProductID;
            prs.CreateReview(productReview2);

            List <ProductReview> productReviews = (from p in db.ProductReview
                                                   where p.ProductID.Equals(product.ProductID)
                                                   select p).ToList();

            Assert.AreEqual(2, productReviews.Count);
            prs.DeleteReview(productReview1);
            prs.DeleteReview(productReview2);
            pr.DeleteProduct(product);
        }
Esempio n. 3
0
        public void CreateDeleteReviewTest()
        {
            AdventureWorksDataContext db  = new AdventureWorksDataContext();
            ProductService            pr  = new ProductService();
            ProductReviewService      prs = new ProductReviewService();

            Product product = new Product();

            product.Name          = "Test-Create-ProductReview";
            product.ProductNumber = "Test-Number-CD-PR";

            pr.CreateProduct(product);

            ProductReview productReview = new ProductReview();

            productReview.Rating    = 1;
            productReview.Comments  = "Comments-Test";
            productReview.ProductID = product.ProductID;

            prs.CreateReview(productReview);

            ProductReview actualProductReview = (from p in db.ProductReview
                                                 where p.Comments.Equals(productReview.Comments)
                                                 select p).First();

            Assert.AreEqual(1, actualProductReview.Rating);

            prs.DeleteReview(productReview);

            List <ProductReview> actualProductsReviewsAfterDelete = (from p in db.ProductReview
                                                                     where p.Comments.Equals(productReview.Comments)
                                                                     select p).ToList();

            Assert.AreEqual(0, actualProductsReviewsAfterDelete.Count);
            pr.DeleteProduct(product);
        }
Esempio n. 4
0
 public void AddReview(ProductReview review)
 {
     review.ProductID = Product.ProductID;
     productReviewService.CreateReview(review);
     GetReviews();
 }