Exemple #1
0
        public async Task GetCommentByIDAsyncShouldReturnComment()
        {
            using (var context = new MusicDBContext(options))
            {
                IMusicRepoDB _repo = new MusicRepoDB(context);

                Comments testComment = new Comments();
                testComment.Id            = 1;
                testComment.Comment       = "First Comment";
                testComment.CommentData   = DateTime.Parse("2021-03-15 18:17:00");
                testComment.UserId        = 2;
                testComment.UploadMusicId = 1;
                var foundComment = await _repo.GetCommentByIDAsync(1);

                Assert.Equal(1, testComment.Id);
            }
        }
Exemple #2
0
        public async Task DeleteCommentAsyncShouldDeleteComment()
        {
            using (var context = new MusicDBContext(options))
            {
                IMusicRepoDB _repo       = new MusicRepoDB(context);
                Comments     testComment = new Comments();
                testComment.Id            = 4;
                testComment.Comment       = "First Comment";
                testComment.CommentData   = DateTime.Parse("2021-03-15 18:17:00");
                testComment.UserId        = 2;
                testComment.UploadMusicId = 1;
                var newComment = await _repo.AddCommentAsync(testComment);

                var deletedComment = await _repo.DeleteCommentAsync(testComment);

                using (var assertContext = new MusicDBContext(options))
                {
                    var result = await _repo.GetCommentByIDAsync(4);

                    Assert.Null(result);
                }
            }
        }