public void GetAllSongsByACertainUserTest() { System.Threading.Thread.Sleep(TimeSpan.FromSeconds(2)); 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 user -- generates with null as username var user = new User(); // create a song -- generates with null as artist name var song = new Song(); repository.songs.Add(song); repository.users.Add(user); context.SaveChanges(); // gets list where artist name matches username var s = songController.GetAllSongsByACertainUser(user.Id); // list is not empty because we create song and user with null Assert.NotEmpty(s.Result); } }