public async Task Put_GivenSongExists_UpdateExistingSongInDatabase() { var song = new Song { Artist = "artist", Difficulty = "difficulty", Level = 5, Name = "name" }; var songEntity = await _fixture._context.Songs.AddAsync(song); await _fixture._context.SaveChangesAsync(); song = songEntity.Entity; var expectedSongResponse = new SongResponse { Artist = "newArtist", Difficulty = "difficulty", Level = 15, Name = "name", Id = song.Id }; var actionResult = await _songsController.Put( song.Id, new SongRequest { Artist = "newArtist", Difficulty = "difficulty", Level = 15, Name = "name", }); var songFromDatabase = await _fixture._context.Songs.FindAsync(song.Id); var songFromDatabaseAsResponse = SongResponse.FromEntity(songFromDatabase); var okObjectResult = Assert.IsType <OkObjectResult>(actionResult.Result); var songResponse = Assert.IsAssignableFrom <SongResponse>(okObjectResult.Value); Assert.Equal(songFromDatabaseAsResponse, songResponse); Assert.Equal(expectedSongResponse, songResponse); }
public void SongsPut() { var testSubject = new SongsController(_testRepo); var newObject = new Song() { Id = 1, Artist = "TestArtist" }; testSubject.Put(1, newObject); Assert.IsTrue(_testRepo.Get(1).Artist == "TestArtist"); }