Exemple #1
0
        public async Task GetAllReviewsForProductId_NonExistentProduct()
        {
            var service = new FakeReviewService(testReviews);
            var result  = await service.GetReviewListAsync(13, null, false, false);

            Assert.IsNotNull(result);

            var reviewsResult = result as IEnumerable <ReviewDto>;

            Assert.IsNotNull(reviewsResult);
            Assert.IsTrue(reviewsResult.All(r => r.productId == 13));

            var reviewsList    = reviewsResult.ToList();
            var limitedReviews = service._reviews.FindAll(r => r.hidden == false && r.deleted == false && r.productId == 13);

            Assert.AreEqual(limitedReviews.Count, reviewsList.Count);

            for (int i = 0; i < limitedReviews.Count; ++i)
            {
                Assert.AreEqual(limitedReviews[i].reviewId, reviewsList[i].reviewId);
                Assert.AreEqual(limitedReviews[i].productId, reviewsList[i].productId);
                Assert.AreEqual(limitedReviews[i].userId, reviewsList[i].userId);
                Assert.AreEqual(limitedReviews[i].userName, reviewsList[i].userName);
                Assert.AreEqual(limitedReviews[i].reviewRating, reviewsList[i].reviewRating);
            }
        }
Exemple #2
0
        public async Task GetAllReviews_Positive()
        {
            var service = new FakeReviewService(testReviews);
            var result  = await service.GetReviewListAsync(null, null, false, false);

            Assert.IsNotNull(result);

            var reviewsResult = result as IEnumerable <ReviewDto>;

            Assert.IsNotNull(reviewsResult);

            var resultList  = reviewsResult.ToList();
            var reviewCount = service._reviews.Where(r => r.hidden == false && r.deleted == false).Count();

            Assert.AreEqual(reviewCount, resultList.Count());

            for (int i = 0; i < resultList.Count(); ++i)
            {
                Assert.AreEqual(service._reviews[i].reviewId, resultList[i].reviewId);
                Assert.AreEqual(service._reviews[i].productId, resultList[i].productId);
                Assert.AreEqual(service._reviews[i].userId, resultList[i].userId);
                Assert.AreEqual(service._reviews[i].userName, resultList[i].userName);
                Assert.AreEqual(service._reviews[i].reviewRating, resultList[i].reviewRating);
            }
        }