Example #1
0
        public async Task GetNameByIdAsyncWithCorrectDataShouldReturnCorrectResult()
        {
            var options = new DbContextOptionsBuilder <ApplicationDbContext>()
                          .UseInMemoryDatabase(databaseName: Guid.NewGuid().ToString()).Options;
            var dbContext             = new ApplicationDbContext(options);
            var genresRepository      = new EfDeletableEntityRepository <Genre>(dbContext);
            var groupGenresRepository = new EfRepository <GroupGenre>(dbContext);
            var genresService         = new GenresService(groupGenresRepository, genresRepository);

            await genresRepository.AddAsync(new Genre { Name = "Power metal" });

            await genresRepository.SaveChangesAsync();

            var actual = await genresService.GetNameByIdAsync(1);

            var expected = "Power metal";

            Assert.Equal(expected, actual);
        }