示例#1
0
        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);
            }
        }
示例#2
0
        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);
            }
        }
示例#3
0
        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);
                }
            }
        }
示例#4
0
        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);
            }
        }