diff --git a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs index 69462870ff..88e8d459b1 100644 --- a/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs +++ b/modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs @@ -15,10 +15,10 @@ namespace Volo.CmsKit.Admin.Comments public Guid? RepliedCommentId { get; set; } - public Guid CreatorId { get; set; } + public Guid? CreatorId { get; set; } - public DateTime CreationStartDate { get; set; } + public DateTime? CreationStartDate { get; set; } - public DateTime CreationEndDate { get; set; } + public DateTime? CreationEndDate { get; set; } } } \ No newline at end of file diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs new file mode 100644 index 0000000000..e42312a97b --- /dev/null +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs @@ -0,0 +1,49 @@ +using System.Threading.Tasks; +using Shouldly; +using Volo.Abp.Domain.Entities; +using Volo.CmsKit.Admin.Comments; +using Xunit; + +namespace Volo.CmsKit.Comments +{ + public class CommentAdminAppService_Tests : CmsKitApplicationTestBase + { + private readonly ICommentAdminAppService _commentAdminAppService; + private readonly CmsKitTestData _cmsKitTestData; + + public CommentAdminAppService_Tests() + { + _commentAdminAppService = GetRequiredService(); + _cmsKitTestData = GetRequiredService(); + } + + [Fact] + public async Task ShouldGet_PagedListAsync() + { + var comments = await _commentAdminAppService.GetListAsync(new CommentGetListInput + { + MaxResultCount = 3 + }); + + comments.TotalCount.ShouldBe(6); + comments.Items.Count.ShouldBe(3); + } + + [Fact] + public async Task ShouldGet_CommentWithAuthorAsync() + { + var comment = await _commentAdminAppService.GetAsync(_cmsKitTestData.CommentWithChildId); + + comment.ShouldNotBeNull(); + comment.Author.ShouldNotBeNull(); + } + + [Fact] + public async Task ShouldDelete_WithRepliesAsync() + { + await _commentAdminAppService.DeleteAsync(_cmsKitTestData.CommentWithChildId); + + await Should.ThrowAsync(async () => await _commentAdminAppService.GetAsync(_cmsKitTestData.CommentWithChildId)); + } + } +} \ No newline at end of file diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs index 80b3052798..e7b36a242a 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs @@ -18,6 +18,31 @@ namespace Volo.CmsKit.Comments _commentRepository = GetRequiredService(); } + [Fact] + public async Task GetList_ShouldWork() + { + var comments = await _commentRepository.GetListAsync(); + + comments.ShouldNotBeNull(); + comments.Count.ShouldBe(6); + + var headCommentId = comments.First(x => x.RepliedCommentId != null).RepliedCommentId; + + var replies = await _commentRepository.GetListAsync(repliedCommentId: headCommentId); + + replies.ShouldNotBeNull(); + replies.Count.ShouldBeLessThan(6); + replies.Count.ShouldBeGreaterThanOrEqualTo(1); + } + + [Fact] + public async Task GetCount_ShouldWork() + { + var commentsCount = await _commentRepository.GetCountAsync(); + + commentsCount.ShouldBe(6); + } + [Fact] public async Task GetListWithAuthorsAsync() {