public void AddReviewAsyncThrowsArgumentExceptionWhenUserReviewExists()
        {
            var webtoons = new List <Webtoon>();

            webtoons.Add(new Webtoon
            {
                Id          = "test",
                TitleNumber = "123"
            });
            var mockWebtoonsRepo = new Mock <IWebtoonsRepository>();

            mockWebtoonsRepo.Setup(x => x.GetWebtoonByTitleNumber("123")).Returns(webtoons.First());
            var reviews         = new List <Review>();
            var mockReviewsRepo = new Mock <IReviewsRepository>();

            mockReviewsRepo.Setup(x => x.All()).Returns(reviews.AsQueryable());
            reviews.Add(new Review()
            {
                ReviewAuthorId = "gosho",
                WebtoonId      = "test"
            });

            var service = new ReviewsService(mockReviewsRepo.Object, mockWebtoonsRepo.Object);

            Assert.ThrowsAsync <ArgumentException>(() => service.AddReviewAsync(new Web.ViewModels.Reviews.LeaveReviewInputModel()
            {
                UserId             = "gosho",
                WebtoonTitleNumber = "123"
            }));
        }
        public async Task AddReviewAsyncWorksCorrectly()
        {
            var webtoons = new List <Webtoon>();

            webtoons.Add(new Webtoon
            {
                Id          = "test",
                TitleNumber = "123"
            });
            var mockWebtoonsRepo = new Mock <IWebtoonsRepository>();

            mockWebtoonsRepo.Setup(x => x.GetWebtoonByTitleNumber("123")).Returns(webtoons.First());
            var reviews         = new List <Review>();
            var mockReviewsRepo = new Mock <IReviewsRepository>();

            mockReviewsRepo.Setup(x => x.All()).Returns(reviews.AsQueryable());
            mockReviewsRepo.Setup(x => x.AddAsync(It.IsAny <Review>())).Callback((Review review) => reviews.Add(review));

            var service = new ReviewsService(mockReviewsRepo.Object, mockWebtoonsRepo.Object);

            await service.AddReviewAsync(new Web.ViewModels.Reviews.LeaveReviewInputModel()
            {
                UserId             = "gosho",
                UserReview         = "This should work",
                WebtoonTitleNumber = "123"
            });

            Assert.Single(reviews);
            Assert.Equal("gosho", reviews.First().ReviewAuthorId);
            Assert.Equal("This should work", reviews.First().ReviewInfo);
        }