|
|
|
@ -1,4 +1,5 @@ |
|
|
|
using System; |
|
|
|
using System.Linq; |
|
|
|
using System.Threading.Tasks; |
|
|
|
using Shouldly; |
|
|
|
using Volo.Abp.Uow; |
|
|
|
@ -24,6 +25,33 @@ namespace Volo.CmsKit.Pages |
|
|
|
_contentRepository = GetRequiredService<IContentRepository>(); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task ShouldGetListAsync() |
|
|
|
{ |
|
|
|
var input = new GetPagesInputDto(); |
|
|
|
|
|
|
|
var pages = await _pageAdminAppService.GetListAsync(input); |
|
|
|
|
|
|
|
pages.TotalCount.ShouldBe(2); |
|
|
|
pages.Items.Count.ShouldBe(2); |
|
|
|
|
|
|
|
input.MaxResultCount = 1; |
|
|
|
|
|
|
|
var pages2 = await _pageAdminAppService.GetListAsync(input); |
|
|
|
|
|
|
|
pages2.TotalCount.ShouldBe(2); |
|
|
|
pages2.Items.Count.ShouldBe(1); |
|
|
|
pages2.Items.First().Title.ShouldBe(_data.Page_1_Title); |
|
|
|
|
|
|
|
input.SkipCount = 1; |
|
|
|
|
|
|
|
var pages3 = await _pageAdminAppService.GetListAsync(input); |
|
|
|
|
|
|
|
pages3.TotalCount.ShouldBe(2); |
|
|
|
pages3.Items.Count.ShouldBe(1); |
|
|
|
pages3.Items.First().Title.ShouldBe(_data.Page_2_Title); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task ShouldGetAsync() |
|
|
|
{ |
|
|
|
@ -38,10 +66,11 @@ namespace Volo.CmsKit.Pages |
|
|
|
var dto = new CreatePageInputDto |
|
|
|
{ |
|
|
|
Title = "test", |
|
|
|
Url = "test-url" |
|
|
|
Url = "test-url", |
|
|
|
Content = "test-content" |
|
|
|
}; |
|
|
|
|
|
|
|
await Should.NotThrowAsync(async () => await _pageAdminAppService.CreatePageAsync(dto)); |
|
|
|
await Should.NotThrowAsync(async () => await _pageAdminAppService.CreateAsync(dto)); |
|
|
|
|
|
|
|
var page = await _pageRepository.GetByUrlAsync(dto.Url); |
|
|
|
|
|
|
|
@ -54,23 +83,24 @@ namespace Volo.CmsKit.Pages |
|
|
|
var dto = new CreatePageInputDto |
|
|
|
{ |
|
|
|
Title = "test", |
|
|
|
Url = _data.Page_1_Url |
|
|
|
Url = _data.Page_1_Url, |
|
|
|
Content = "test-content" |
|
|
|
}; |
|
|
|
|
|
|
|
await Should.ThrowAsync<Exception>(async () => await _pageAdminAppService.CreatePageAsync(dto)); |
|
|
|
await Should.ThrowAsync<Exception>(async () => await _pageAdminAppService.CreateAsync(dto)); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task ShouldCreateWithContentAsync() |
|
|
|
{ |
|
|
|
var dto = new CreatePageWithContentInputDto |
|
|
|
var dto = new CreatePageInputDto |
|
|
|
{ |
|
|
|
Title = "test", |
|
|
|
Url = "test-url", |
|
|
|
Content = "my-test-content" |
|
|
|
}; |
|
|
|
|
|
|
|
await Should.NotThrowAsync(async () => await _pageAdminAppService.CreatePageWithContentAsync(dto)); |
|
|
|
await Should.NotThrowAsync(async () => await _pageAdminAppService.CreateAsync(dto)); |
|
|
|
|
|
|
|
var page = await _pageRepository.GetByUrlAsync(dto.Url); |
|
|
|
|
|
|
|
@ -82,14 +112,14 @@ namespace Volo.CmsKit.Pages |
|
|
|
[Fact] |
|
|
|
public async Task ShouldNotCreateWithContentAsync() |
|
|
|
{ |
|
|
|
var dto = new CreatePageWithContentInputDto |
|
|
|
var dto = new CreatePageInputDto |
|
|
|
{ |
|
|
|
Title = "test", |
|
|
|
Url = _data.Page_1_Url, |
|
|
|
Content = "my-test-content" |
|
|
|
}; |
|
|
|
|
|
|
|
await Should.ThrowAsync<Exception>(async () => await _pageAdminAppService.CreatePageWithContentAsync(dto)); |
|
|
|
await Should.ThrowAsync<Exception>(async () => await _pageAdminAppService.CreateAsync(dto)); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
@ -99,10 +129,11 @@ namespace Volo.CmsKit.Pages |
|
|
|
{ |
|
|
|
Title = _data.Page_1_Title + "++", |
|
|
|
Description = "new description", |
|
|
|
Url = _data.Page_1_Url+ "test" |
|
|
|
Url = _data.Page_1_Url+ "test", |
|
|
|
Content = _data.Page_1_Content + "+" |
|
|
|
}; |
|
|
|
|
|
|
|
await Should.NotThrowAsync(async () => await _pageAdminAppService.UpdatePageAsync(_data.Page_1_Id, dto)); |
|
|
|
await Should.NotThrowAsync(async () => await _pageAdminAppService.UpdateAsync(_data.Page_1_Id, dto)); |
|
|
|
|
|
|
|
var updatedPage = await _pageRepository.GetAsync(_data.Page_1_Id); |
|
|
|
|
|
|
|
@ -123,21 +154,17 @@ namespace Volo.CmsKit.Pages |
|
|
|
{ |
|
|
|
Title = _data.Page_1_Title + "++", |
|
|
|
Description = "new description", |
|
|
|
Url = _data.Page_2_Url |
|
|
|
Url = _data.Page_2_Url, |
|
|
|
Content = _data.Page_1_Content + "+" |
|
|
|
}; |
|
|
|
|
|
|
|
await Should.ThrowAsync<Exception>(async () => await _pageAdminAppService.UpdatePageAsync(_data.Page_1_Id, dto)); |
|
|
|
await Should.ThrowAsync<Exception>(async () => await _pageAdminAppService.UpdateAsync(_data.Page_1_Id, dto)); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task ShouldBeExistAsync() |
|
|
|
{ |
|
|
|
var dto = new CheckUrlInputDto |
|
|
|
{ |
|
|
|
Url = _data.Page_1_Url |
|
|
|
}; |
|
|
|
|
|
|
|
var doesExist = await _pageAdminAppService.DoesUrlExistAsync(dto); |
|
|
|
var doesExist = await _pageAdminAppService.ExistsAsync(_data.Page_1_Url); |
|
|
|
|
|
|
|
doesExist.ShouldBeTrue(); |
|
|
|
} |
|
|
|
@ -145,31 +172,11 @@ namespace Volo.CmsKit.Pages |
|
|
|
[Fact] |
|
|
|
public async Task ShouldNotBeExistAsync() |
|
|
|
{ |
|
|
|
var dto = new CheckUrlInputDto |
|
|
|
{ |
|
|
|
Url = _data.Page_1_Url+ "+" |
|
|
|
}; |
|
|
|
|
|
|
|
var doesExist = await _pageAdminAppService.DoesUrlExistAsync(dto); |
|
|
|
var doesExist = await _pageAdminAppService.ExistsAsync(_data.Page_1_Url+ "+"); |
|
|
|
|
|
|
|
doesExist.ShouldBeFalse(); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task ShouldUpdateContentAsync() |
|
|
|
{ |
|
|
|
var dto = new UpdatePageContentInputDto |
|
|
|
{ |
|
|
|
Content = "my-new-content" |
|
|
|
}; |
|
|
|
|
|
|
|
await Should.NotThrowAsync(async () => await _pageAdminAppService.UpdatePageContentAsync(_data.Page_1_Id, dto)); |
|
|
|
|
|
|
|
var content = await _contentRepository.GetAsync(nameof(Page), _data.Page_1_Id.ToString()); |
|
|
|
|
|
|
|
content.Value.ShouldBe(dto.Content); |
|
|
|
} |
|
|
|
|
|
|
|
[Fact] |
|
|
|
public async Task ShouldDeleteAsync() |
|
|
|
{ |
|
|
|
|