public void GetSongByIdAsyncTest() { var options = new DbContextOptionsBuilder <ApplicationDbContext>() .UseInMemoryDatabase(databaseName: "InHarmonyTestControllerDB") .Options; using (var context = new ApplicationDbContext(options)) { context.Database.EnsureDeleted(); context.Database.EnsureCreated(); Repository repository = new Repository(context, _repositoryLogger); BusinessLogicClass logic = new BusinessLogicClass(repository, _mapperClass, _repositoryLogger); SongController songController = new SongController(logic, _songControllerLogger); // create a song var song = new Song(); repository.songs.Add(song); context.SaveChanges(); Assert.NotNull(songController.GetSongByIdAsync(song.Id)); } }