public async Task AddPlayListAsyncShouldAddPlayList() { using (var context = new MusicDBContext(options)) { IMusicRepoDB _repo = new MusicRepoDB(context); PlayList testPlayList = new PlayList(); testPlayList.UserId = 1; testPlayList.Name = "Songs to git gud too"; var newPlayList = await _repo.AddPlayListAsync(testPlayList); Assert.NotNull(newPlayList); Assert.Equal("Songs to git gud too", newPlayList.Name); } }
public async Task GetPlayListByIDAsyncShouldReturnPlayList() { using (var context = new MusicDBContext(options)) { IMusicRepoDB _repo = new MusicRepoDB(context); PlayList testPlayList = new PlayList(); testPlayList.Id = 4; testPlayList.UserId = 1; testPlayList.Name = "Songs to git gud too"; var newPlayList = await _repo.AddPlayListAsync(testPlayList); var foundPlayList = await _repo.GetPlayListByIDAsync(4); Assert.NotNull(foundPlayList); Assert.Equal(4, foundPlayList.Id); } }
public async Task DeletePlayListAsyncShouldDeletePlayList() { using (var context = new MusicDBContext(options)) { IMusicRepoDB _repo = new MusicRepoDB(context); PlayList testPlayList = new PlayList(); testPlayList.Id = 4; testPlayList.UserId = 1; testPlayList.Name = "Songs to git gud too"; var newPlayList = await _repo.AddPlayListAsync(testPlayList); var deletePlayList = await _repo.DeletePlayListAsync(testPlayList); using (var assertContext = new MusicDBContext(options)) { var result = assertContext.PlayList.Find(4); Assert.Null(result); } } }
public async Task UpdatePlayListAsyncShouldUpdatePlayList() { using (var context = new MusicDBContext(options)) { IMusicRepoDB _repo = new MusicRepoDB(context); PlayList testPlayList = new PlayList(); testPlayList.Id = 4; testPlayList.UserId = 1; testPlayList.Name = "Songs to git gud too"; ICollection <MusicPlaylist> playListMusicPlaylist = new List <MusicPlaylist>(); MusicPlaylist testMusicPlaylist = new MusicPlaylist(); testMusicPlaylist.Id = 4; testMusicPlaylist.PlayListId = 2; testMusicPlaylist.MusicId = 1; playListMusicPlaylist.Add(testMusicPlaylist); var newPlayList = await _repo.AddPlayListAsync(testPlayList); var updatedPlayList = await _repo.UpdatePlayListAsync(testPlayList); testPlayList.Name = "Git Gud"; Assert.Equal("Git Gud", updatedPlayList.Name); } }