예제 #1
0
 public void GetCommentByID(int commentId)
 {
     ScopeAsync(async (c, t) =>
     {
         var commentRepo = new ImageCommentRepository(c);
         var result = await commentRepo.GetSingleByID(commentId);
         Assert.True(result.HasValue);
     });
 }
예제 #2
0
 public void GetComment(int imageId)
 {
     ScopeAsync(async (c, t) =>
     {
         var commentRepo = new ImageCommentRepository(c);
         var result = await commentRepo.Get(imageId);
         Assert.True(result.Any());
     });
 }
예제 #3
0
 public void GetPageOfComments(int imageId, int skip, int take)
 {
     ScopeAsync(async (c, t) =>
     {
         var commentRepo = new ImageCommentRepository(c);
         var result = await commentRepo.GetPage(skip, take, imageId);
         Assert.True(result.CurrentItems.Any());
     });
 }
예제 #4
0
        public void UpdateComment(int commentId, string updatedRemark)
        {
            ScopeAsync(async (c, t) =>
            {
                // Arrange
                var commentRepo = new ImageCommentRepository(c);
                var updated = new ImageComment
                {
                    PostedOn = DateTime.Now,
                    Text = updatedRemark
                };

                // Act
                var result = await commentRepo.UpdateSingle(commentId, updated);

                // Assert
                Assert.True(result);
            });
        }
예제 #5
0
        public void DeleteComment(int commentId)
        {
            ScopeAsync(async (c, t) =>
            {
                // Arrange
                var commentRepo = new ImageCommentRepository(c);

                // Act
                Func<int, Task> onDelete = (id) => Task.FromResult(0);
                var result = await commentRepo.DeleteSingle(commentId, onDelete);

                // Assert
                Assert.True(result);
            });
        }
예제 #6
0
        public void CreateComment(string remark, int userId, int imageId)
        {
            ScopeAsync(async (c, t) =>
            {
                // Arrange
                var commentRepo = new ImageCommentRepository(c);
                var comment = new ImageComment
                {
                    Author = new User { ID = userId },
                    PostedOn = DateTime.Now,
                    Text = remark,
                };

                // Act
                Func<ImageComment, Task> onCreate = com => Task.FromResult(0);
                var result = await commentRepo.CreateSingle(comment, onCreate);

                // Assert
                Assert.True(result.HasValue);
            });
        }