Example #1
0
        public async Task GetAllGenresShouldReturnCorrectGenresWhenTakeAndSkip()
        {
            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.GetAllGenresAsync <GenreTestModel>(2, 1);

            Assert.Equal(2, result.Count());
        }