Esempio n. 1
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);
        }