Пример #1
0
        public async Task AddCommentAsyncShouldAddComment()
        {
            using (var context = new MusicDBContext(options))
            {
                IMusicRepoDB _repo       = new MusicRepoDB(context);
                Comments     testComment = new Comments();
                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);

                Assert.Equal("First Comment", newComment.Comment);
            }
        }
Пример #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);
                }
            }
        }