Browse Source

Added comment admin app service test

pull/7757/head
Ahmet 5 years ago
parent
commit
e109fd9260
  1. 6
      modules/cms-kit/src/Volo.CmsKit.Admin.Application.Contracts/Volo/CmsKit/Admin/Comments/CommentGetListInput.cs
  2. 49
      modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentAdminAppService_Tests.cs
  3. 25
      modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs

6
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; }
}
}

49
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<ICommentAdminAppService>();
_cmsKitTestData = GetRequiredService<CmsKitTestData>();
}
[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<EntityNotFoundException>(async () => await _commentAdminAppService.GetAsync(_cmsKitTestData.CommentWithChildId));
}
}
}

25
modules/cms-kit/test/Volo.CmsKit.TestBase/Comments/CommentRepository_Tests.cs

@ -18,6 +18,31 @@ namespace Volo.CmsKit.Comments
_commentRepository = GetRequiredService<ICommentRepository>();
}
[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()
{

Loading…
Cancel
Save