예제 #1
0
        public async Task DoesReviewIdExistShouldReturnFalseIfNotFound()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);
            await db.AddRangeAsync(
                new Review
            {
                Description = "description1",
                AuthorId    = "author1",
                BookId      = 1,
            },
                new Review
            {
                Description = "description2",
                AuthorId    = "author1",
                BookId      = 1,
                ParentId    = 1,
            });

            await db.SaveChangesAsync();

            var reviewsService = new ReviewsService(db);

            var result = await reviewsService.DoesReviewIdExistAsync(5);

            Assert.False(result);
        }
예제 #2
0
        public async Task EditReviewShouldWorkCorrectly(string description, ReadingProgress progress, bool thisEdition)
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);
            await db.AddAsync(
                new Review
            {
                Description     = "description1",
                AuthorId        = "author1",
                BookId          = 1,
                ReadingProgress = ReadingProgress.Unknown,
                ThisEdition     = false,
            });

            await db.SaveChangesAsync();

            var reviewsService = new ReviewsService(db);

            await reviewsService.EditReviewAsync(1, description, progress, thisEdition);

            var result = await db.Reviews.FirstOrDefaultAsync();

            Assert.NotNull(result.ModifiedOn);
            Assert.Equal(description, result.Description);
            Assert.Equal(progress, result.ReadingProgress);
            Assert.Equal(thisEdition, result.ThisEdition);
        }
예제 #3
0
        public async Task AreReviewsAboutSameBookShouldReturnFalseIfDeleted()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);
            await db.AddRangeAsync(
                new Review
            {
                Description     = "description1",
                AuthorId        = "author1",
                BookId          = 1,
                ReadingProgress = ReadingProgress.Finished,
                IsDeleted       = true,
            },
                new Review
            {
                Description     = "description2",
                AuthorId        = "author2",
                BookId          = 1,
                ReadingProgress = ReadingProgress.Finished,
            });

            await db.SaveChangesAsync();

            var reviewsService = new ReviewsService(db);

            var result = await reviewsService.AreReviewsAboutSameBookAsync(1, 1);

            Assert.False(result);
        }
예제 #4
0
        public async Task GetAuthorIdByIdShouldReturnNullIfDeleted()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);
            await db.AddRangeAsync(
                new Review
            {
                Description = "description1",
                AuthorId    = "author1",
                BookId      = 1,
                IsDeleted   = true,
            },
                new Review
            {
                Description = "description2",
                AuthorId    = "author1",
                BookId      = 1,
                ParentId    = 1,
            });

            await db.SaveChangesAsync();

            var reviewsService = new ReviewsService(db);

            var result = await reviewsService.GetAuthorIdByIdAsync(1);

            Assert.Null(result);
        }
        public async Task GetAllLanguagesShouldReturnTheCorrectCount()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            var languages = new List <EditionLanguage>();

            for (int i = 1; i <= 10; i++)
            {
                languages.Add(
                    new EditionLanguage
                {
                    Name = $"test{i}",
                });
            }

            await db.EditionLanguages.AddRangeAsync(languages);

            await db.SaveChangesAsync();

            var languagesService = new EditionLanguagesService(db);

            var result = await languagesService.GetAllLanguagesAsync <LanguageTestModel>();

            Assert.Equal(10, result.Count());
        }
예제 #6
0
        public async Task GetChildrenReviewsToReviewsAsyncShouldNotReturnReviewsWithOtherBookId()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);
            await db.AddRangeAsync(
                new Review
            {
                Description = "description1",
                AuthorId    = "author1",
                BookId      = 1,
            },
                new Review
            {
                Description = "description2",
                AuthorId    = "author1",
                BookId      = 1,
            },
                new Review
            {
                Description = "description3",
                AuthorId    = "author1",
                BookId      = 1,
                ParentId    = 1,
            },
                new Review
            {
                Description = "description4",
                AuthorId    = "author1",
                BookId      = 2,
                ParentId    = 2,
            },
                new Review
            {
                Description = "description4",
                AuthorId    = "author1",
                BookId      = 1,
                ParentId    = 3,
            },
                new Review
            {
                Description = "description4",
                AuthorId    = "author1",
                BookId      = 1,
                ParentId    = 4,
            });

            await db.SaveChangesAsync();

            var reviewsService = new ReviewsService(db);

            var ids = new List <int> {
                1, 2
            };
            var result = await reviewsService.GetChildrenReviewsToReviewsAsync <ReviewTestModel>(ids, 1);

            Assert.Equal(2, result.Count());
        }
예제 #7
0
        public async Task EditGenreShouldWorkCorrectly(string name, string description)
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);
            await db.Genres.AddAsync(
                new Genre
            {
                Name        = "test",
                Description = "description",
            });

            await db.SaveChangesAsync();

            var genresService = new GenresService(db);

            await genresService.EditGenreAsync(1, name, description);

            var result = await db.Genres.FirstOrDefaultAsync();

            Assert.Equal(name, result.Name);
            Assert.Equal(description, result.Description);
            Assert.NotNull(result.ModifiedOn);
        }
        public async Task DoesEditionLanguageExistShouldReturnFalseWhenNotFound()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            await db.EditionLanguages.AddRangeAsync(
                new EditionLanguage
            {
                Name = "test1",
            },
                new EditionLanguage
            {
                Name = "test2",
            },
                new EditionLanguage
            {
                Name = "test3",
            });

            await db.SaveChangesAsync();

            var languagesService = new EditionLanguagesService(db);

            Assert.False(await languagesService.DoesEditionLanguageIdExistAsync(5));
        }
예제 #9
0
        public async Task GetGenreShouldReturnCorrectGenre()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);
            await db.Genres.AddRangeAsync(
                new Genre
            {
                Name        = "test1",
                Description = "description1",
            },
                new Genre
            {
                Name        = "test2",
                Description = "description2",
            },
                new Genre
            {
                Name        = "test3",
                Description = "description3",
                IsDeleted   = true,
            });

            await db.SaveChangesAsync();

            var genresService = new GenresService(db);

            var result = await genresService.GetGenreByIdAsync <GenreTestModel>(1);

            Assert.Equal("test1", result.Name);
            Assert.Equal("description1", result.Description);
        }
예제 #10
0
        public async Task GetRandomGenresShouldNotReturnDeletedGenres()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);
            await db.Genres.AddRangeAsync(
                new Genre
            {
                Name        = "test1",
                Description = "description1",
                IsDeleted   = true,
            },
                new Genre
            {
                Name        = "test2",
                Description = "description2",
                IsDeleted   = true,
            },
                new Genre
            {
                Name        = "test3",
                Description = "description3",
            });

            await db.SaveChangesAsync();

            var genresService = new GenresService(db);

            var result = await genresService.GetRandomGenresAsync <GenreTestModel>(2);

            Assert.Single(result);
        }
예제 #11
0
        public async Task GetGenresCountShouldReturnCorrectCount()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);
            await db.Genres.AddRangeAsync(
                new Genre
            {
                Name        = "test1",
                Description = "description1",
            },
                new Genre
            {
                Name        = "test2",
                Description = "description2",
            },
                new Genre
            {
                Name        = "test3",
                Description = "description3",
            });

            await db.SaveChangesAsync();

            var genresService = new GenresService(db);

            var result = await genresService.GetGenresCountAsync();

            Assert.Equal(3, result);
        }
예제 #12
0
        public async Task DeleteGenreShouldSetIsDeletedAndDeletedOn()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);
            await db.Genres.AddAsync(
                new Genre
            {
                Name        = "test",
                Description = "description",
            });

            await db.SaveChangesAsync();

            var genresService = new GenresService(db);

            await genresService.DeleteGenreByIdAsync(1);

            var result = await db.Genres.FirstOrDefaultAsync();

            Assert.True(result.IsDeleted);
            Assert.NotNull(result.DeletedOn);
        }
예제 #13
0
        public async Task GetAllTagsMethodShouldReturnCorrectCountWhenBothTakeAndSkipAreGiven()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db   = new AlexandriaDbContext(options);
            var tags = new List <Tag>();

            for (int i = 1; i <= 10; i++)
            {
                tags.Add(new Tag
                {
                    Name      = $"test{i}",
                    CreatedOn = DateTime.UtcNow,
                });
            }

            await db.AddRangeAsync(tags);

            await db.SaveChangesAsync();

            var tagsService = new TagsService(db);
            var resultTags  = await tagsService.GetAllTagsAsync <TagTestModel>(5, 5);

            Assert.Equal(5, resultTags.ToList().Count());
        }
예제 #14
0
        public async Task GetAllTagsMethodShouldReturnZeroIfTagsAreDeleted()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db   = new AlexandriaDbContext(options);
            var tags = new List <Tag>();

            for (int i = 1; i <= 10; i++)
            {
                tags.Add(new Tag
                {
                    Name      = $"test{i}",
                    CreatedOn = DateTime.UtcNow,
                    IsDeleted = true,
                    DeletedOn = DateTime.UtcNow,
                });
            }

            await db.AddRangeAsync(tags);

            await db.SaveChangesAsync();

            var tagsService = new TagsService(db);
            var resultTags  = await tagsService.GetAllTagsAsync <TagTestModel>();

            Assert.Empty(resultTags.ToList());
        }
예제 #15
0
        public async Task GetAllReviewsByAuthorIdShouldReturnAllReviews()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);
            await db.AddRangeAsync(
                new Review
            {
                Description = "description1",
                AuthorId    = "author1",
            },
                new Review
            {
                Description = "description1",
                AuthorId    = "author1",
            },
                new Review
            {
                Description = "description1",
                AuthorId    = "author1",
            });

            await db.SaveChangesAsync();

            var reviewsService = new ReviewsService(db);

            var result = await reviewsService.GetAllReviewsByAuthorIdAsync <ReviewTestModel>("author1");

            Assert.Equal(3, result.Count());
        }
예제 #16
0
        public async Task GetAuthorByIdShouldReturnNullWhenDeleted()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            await db.Authors.AddAsync(
                new Author
            {
                FirstName  = "first1",
                SecondName = "second1",
                LastName   = "last1",
                IsDeleted  = true,
                DeletedOn  = DateTime.UtcNow,
            });

            await db.SaveChangesAsync();

            var authorsService = new AuthorsService(db);

            var result = await authorsService.GetAuthorByIdAsync <AuthorTestModel>(1);

            Assert.Null(result);
        }
예제 #17
0
        public async Task GetTagsCountMethodShouldReturnTheCorrectCountIfThereAreDeletedTags()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            await db.Tags.AddRangeAsync(
                new Tag
            {
                Name      = "test1",
                CreatedOn = DateTime.UtcNow,
            },
                new Tag
            {
                Name      = "test2",
                CreatedOn = DateTime.UtcNow,
                IsDeleted = true,
                DeletedOn = DateTime.UtcNow,
            },
                new Tag
            {
                Name      = "test3",
                CreatedOn = DateTime.UtcNow,
            });

            await db.SaveChangesAsync();

            var tagsService = new TagsService(db);

            Assert.Equal(2, await tagsService.GetTagsCountAsync());
        }
예제 #18
0
        public async Task GetAverageRatingByBookIdShouldZeroWhenBookIdIsInvalid()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            var ratings = new List <StarRating>();

            for (int i = 1; i <= 2; i++)
            {
                ratings.Add(
                    new StarRating
                {
                    Rate   = 5,
                    UserId = "userId",
                    BookId = 1,
                });
            }

            await db.StarRatings.AddRangeAsync(ratings);

            await db.SaveChangesAsync();

            var ratingsService = new StarRatingsService(db);
            var result         = await ratingsService.GetAverageRatingByBookIdAsync(5);

            Assert.Equal(0, result);
        }
예제 #19
0
        public async Task CreateRatingMethodShouldNotChangeCountIfRatingExists()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            await db.StarRatings.AddAsync(
                new StarRating
            {
                Rate   = 1,
                UserId = "userId",
                BookId = 1,
            });

            await db.SaveChangesAsync();

            var starRatingsService = new StarRatingsService(db);

            await starRatingsService.CreateRatingAsync(5, "userId", 1);

            var result = await db.StarRatings.CountAsync();

            Assert.Equal(1, result);
        }
예제 #20
0
        public async Task GetAllRatesByUserIdShouldReturnZeroWhenInvalidUserId()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            var rates = new List <StarRating>();

            for (int i = 1; i <= 10; i++)
            {
                rates.Add(new StarRating
                {
                    Rate   = i,
                    UserId = "userId",
                    BookId = i,
                });
            }

            await db.StarRatings.AddRangeAsync(rates);

            await db.SaveChangesAsync();

            var ratingsService = new StarRatingsService(db);

            var result = await ratingsService.GetAllRatesByUserIdAsync <RatingTestModel>("id");

            Assert.Empty(result);
        }
예제 #21
0
        public async Task GetAllRatesByUserIdShouldReturnCorrectCountWhenTakeAndSkipAreUsed()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            var rates = new List <StarRating>();

            for (int i = 1; i <= 10; i++)
            {
                rates.Add(new StarRating
                {
                    Rate   = i,
                    UserId = "userId",
                    BookId = i,
                });
            }

            await db.StarRatings.AddRangeAsync(rates);

            await db.SaveChangesAsync();

            var ratingsService = new StarRatingsService(db);

            var result = await ratingsService.GetAllRatesByUserIdAsync <RatingTestModel>("userId", 5, 5);

            Assert.Equal(5, result.Count());
        }
        public async Task SeedAsync(AlexandriaDbContext dbContext, IServiceProvider serviceProvider)
        {
            if (dbContext == null)
            {
                throw new ArgumentNullException(nameof(dbContext));
            }

            if (serviceProvider == null)
            {
                throw new ArgumentNullException(nameof(serviceProvider));
            }

            var logger = serviceProvider.GetService <ILoggerFactory>().CreateLogger(typeof(ApplicationDbContextSeeder));

            var seeders = new List <ISeeder>
            {
                new RolesSeeder(),
                new TagsSeeder(),
                new GenresSeeder(),
                new AwardsSeeder(),
                new CountriesSeeder(),
                new EditionLanguagesSeeder(),
                new AdminSeeder(),
            };

            foreach (var seeder in seeders)
            {
                await seeder.SeedAsync(dbContext, serviceProvider);

                await dbContext.SaveChangesAsync();

                logger.LogInformation($"Seeder {seeder.GetType().Name} done.");
            }
        }
예제 #23
0
        public async Task GetRatesCountByBookIdShouldReturnZeroWhenInvalidBookId()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            var rates = new List <StarRating>();

            for (int i = 1; i <= 10; i++)
            {
                rates.Add(new StarRating
                {
                    Rate   = i,
                    UserId = i.ToString(),
                    BookId = 1,
                });
            }

            await db.AddRangeAsync(rates);

            await db.SaveChangesAsync();

            var ratingsService = new StarRatingsService(db);
            var result         = await ratingsService.GetRatesCountByBookIdAsync(3);

            Assert.Equal(0, result);
        }
예제 #24
0
        public async Task CreateUserFollowerShouldDeleteUserFollowerIfExisting()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);
            await db.UserFollowers.AddAsync(
                new UserFollower
            {
                UserId     = "user1",
                FollowerId = "user2",
            });

            await db.SaveChangesAsync();

            var userFollowerService = new UserFollowersService(db);

            await userFollowerService.CreateUserFollowerAsync("user1", "user2");

            var result = await db.UserFollowers.FirstOrDefaultAsync();

            Assert.True(result.IsDeleted);
            Assert.NotNull(result.DeletedOn);
        }
예제 #25
0
        public async Task AddTagsToBookMethodShouldNotAddBookTagsWhichExist()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            await db.BookTags.AddRangeAsync(
                new BookTag
            {
                BookId = 1,
                TagId  = 1,
            },
                new BookTag
            {
                BookId = 1,
                TagId  = 2,
            });

            await db.SaveChangesAsync();

            var bookTagsService = new BookTagsService(db);

            var addTags = new List <int> {
                1, 2, 3, 4, 5, 5, 5, 5, 5, 5
            };

            await bookTagsService.AddTagsToBookAsync(1, addTags);

            Assert.Equal(5, await db.BookTags.CountAsync());
        }
예제 #26
0
        public async Task DoesAwardExistMethodShouldReturnTrueIfExists()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            var awards = new List <Award>
            {
                new Award
                {
                    Name      = "test1",
                    CreatedOn = DateTime.UtcNow,
                },
                new Award
                {
                    Name      = "test2",
                    CreatedOn = DateTime.UtcNow,
                },
                new Award
                {
                    Name      = "test3",
                    CreatedOn = DateTime.UtcNow,
                },
            };

            await db.Awards.AddRangeAsync(awards);

            await db.SaveChangesAsync();

            var awardsService = new AwardsService(db);

            Assert.True(await awardsService.DoesAwardIdExistAsync(1));
        }
예제 #27
0
        public async Task GetAllAwardsShouldReturnZeroWhenAwardsAreDeleted()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);

            var awards = new List <Award>();

            for (int i = 1; i <= 10; i++)
            {
                awards.Add(
                    new Award
                {
                    Name      = $"test{i}",
                    CreatedOn = DateTime.UtcNow,
                    IsDeleted = true,
                    DeletedOn = DateTime.UtcNow,
                });
            }

            await db.Awards.AddRangeAsync(awards);

            await db.SaveChangesAsync();

            var awardsService = new AwardsService(db);
            var result        = await awardsService.GetAllAwardsAsync <AwardTestModel>();

            Assert.Empty(result);
        }
예제 #28
0
        public async Task GetReviewByIdShouldReturnCorrectReview()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);
            await db.AddRangeAsync(
                new Review
            {
                Description = "description1",
                AuthorId    = "author1",
                BookId      = 1,
            },
                new Review
            {
                Description = "description2",
                AuthorId    = "author1",
                BookId      = 1,
                ParentId    = 1,
            });

            await db.SaveChangesAsync();

            var reviewsService = new ReviewsService(db);

            var result = await reviewsService.GetReviewByIdAsync <ReviewTestModel>(2);

            Assert.Equal("description2", result.Description);
            Assert.NotNull(result.ParentId);
        }
예제 #29
0
        public async Task DeleteReviewShouldSetIsDeletedAndDeletedOn()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);
            await db.AddRangeAsync(
                new Review
            {
                Description     = "description1",
                AuthorId        = "author1",
                BookId          = 1,
                ReadingProgress = ReadingProgress.Finished,
            },
                new Review
            {
                Description     = "description2",
                AuthorId        = "author2",
                BookId          = 1,
                ReadingProgress = ReadingProgress.Finished,
            });

            await db.SaveChangesAsync();

            var reviewsService = new ReviewsService(db);

            await reviewsService.DeleteReviewByIdAsync(1);

            var result = await db.Reviews.FirstOrDefaultAsync();

            Assert.NotNull(result.DeletedOn);
            Assert.True(result.IsDeleted);
        }
예제 #30
0
        public async Task GetAllReviewsByAuthorIdShouldReturnCollectionWithCorrectOrder()
        {
            var options = new DbContextOptionsBuilder <AlexandriaDbContext>()
                          .UseInMemoryDatabase(Guid.NewGuid().ToString())
                          .Options;

            var db = new AlexandriaDbContext(options);
            await db.AddRangeAsync(
                new Review
            {
                Description = "description1",
                AuthorId    = "author1",
                Likes       = new List <Like> {
                    new Like {
                        ReviewId = 1, UserId = "1", IsLiked = true
                    }
                },
            },
                new Review
            {
                Description = "description2",
                AuthorId    = "author1",
                Likes       = new List <Like> {
                    new Like {
                        ReviewId = 2, UserId = "1", IsLiked = false
                    }
                },
            },
                new Review
            {
                Description = "description3",
                AuthorId    = "author1",
                Likes       = new List <Like> {
                    new Like {
                        ReviewId = 3, UserId = "1", IsLiked = true
                    }, new Like {
                        ReviewId = 3, UserId = "1", IsLiked = true
                    }
                },
            },
                new Review
            {
                Description = "description4",
                AuthorId    = "author1",
            });

            await db.SaveChangesAsync();

            var reviewsService = new ReviewsService(db);

            var result = await reviewsService.GetAllReviewsByAuthorIdAsync <ReviewTestModel>("author1");

            var resultReviews = result.ToArray();

            Assert.Equal(4, resultReviews.Count());
            Assert.Equal("description3", resultReviews[0].Description);
            Assert.Equal("description1", resultReviews[1].Description);
        }