public async Task GetAllReviews_ShouldOk()
        {
            List <ReviewDto> testReviewDtos = new List <ReviewDto>
            {
                new ReviewDto {
                    reviewId = 1, productId = 1, userId = 1, userName = "******", reviewRating = 5, reviewContent = "Great Product. You can believe me, I'm not a bot.", hidden = false
                },
                new ReviewDto {
                    reviewId = 2, productId = 1, userId = 2, userName = "******", reviewRating = 3, reviewContent = "It's an okay plunger. I expected more.", hidden = false
                },
                new ReviewDto {
                    reviewId = 3, productId = 4, userId = 1, userName = "******", reviewRating = 4, reviewContent = "Good hardbass, although lacking the newest song from Dj Put-in", hidden = false
                },
                new ReviewDto {
                    reviewId = 4, productId = 2, userId = 3, userName = "******", reviewRating = 5, reviewContent = "Great quality", hidden = false
                }
            };

            var mock = new Mock <IReviewService>(MockBehavior.Strict);

            mock.Setup(repo => repo.GetReviewListAsync(null, null, false, false)).ReturnsAsync(testReviewDtos).Verifiable();
            var controller = new ReviewController(mock.Object);

            var result = await controller.GetReviewListAsync(null, null);

            Assert.IsNotNull(result);

            var controllerResult = result as OkObjectResult;

            Assert.IsNotNull(controllerResult);

            var reviewsResult = controllerResult.Value as IEnumerable <ReviewDto>;

            Assert.IsNotNull(reviewsResult);

            var resultList  = reviewsResult.ToList();
            var reviewCount = testReviewDtos.Count();

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

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

            mock.Verify();
            mock.Verify(repo => repo.GetReviewListAsync(null, null, false, false), Times.Once);
        }
        public async Task GetAllReviewsForProductIdandUserId_ShouldNotFound()
        {
            var mock = new Mock <IReviewService>(MockBehavior.Strict);

            mock.Setup(repo => repo.GetReviewListAsync(10, 10, false, false)).ReturnsAsync(null as List <ReviewDto>).Verifiable();
            var controller = new ReviewController(mock.Object);

            var result = await controller.GetReviewListAsync(10, 10);

            Assert.IsNotNull(result);

            var controllerResult = result as NotFoundResult;

            Assert.IsNotNull(controllerResult);

            mock.Verify();
            mock.Verify(repo => repo.GetReviewListAsync(10, 10, false, false), Times.Once);
        }
        public async Task GetAllReviewsForProductIdandUserId_ShouldOk()
        {
            List <ReviewDto> testReviewDtos = new List <ReviewDto>
            {
                new ReviewDto {
                    reviewId = 1, productId = 1, userId = 1, userName = "******", reviewRating = 5, reviewContent = "Great Product. You can believe me, I'm not a bot.", hidden = false
                }
            };

            var mock = new Mock <IReviewService>(MockBehavior.Strict);

            mock.Setup(repo => repo.GetReviewListAsync(1, 1, false, false)).ReturnsAsync(testReviewDtos).Verifiable();
            var controller = new ReviewController(mock.Object);

            var result = await controller.GetReviewListAsync(1, 1);

            Assert.IsNotNull(result);

            var controllerResult = result as OkObjectResult;

            Assert.IsNotNull(controllerResult);

            var reviewsResult = controllerResult.Value as IEnumerable <ReviewDto>;

            Assert.IsNotNull(reviewsResult);
            Assert.IsTrue(reviewsResult.All(r => r.userId == 1 && r.productId == 1));

            var reviewsList = reviewsResult.ToList();

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

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

            mock.Verify();
            mock.Verify(repo => repo.GetReviewListAsync(1, 1, false, false), Times.Once);
        }