diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagAdminAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagAdminAppService_Tests.cs new file mode 100644 index 0000000000..237434ef9f --- /dev/null +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagAdminAppService_Tests.cs @@ -0,0 +1,56 @@ +using Microsoft.Extensions.DependencyInjection; +using NSubstitute; +using Shouldly; +using System; +using System.Threading.Tasks; +using Volo.Abp; +using Volo.Abp.Clients; +using Volo.Abp.Users; +using Volo.Abp.Validation; +using Volo.CmsKit.Admin.Tags; +using Volo.CmsKit.Public.Tags; +using Xunit; + +namespace Volo.CmsKit.Tags +{ + public class TagAdminAppService_Tests : CmsKitApplicationTestBase + { + private readonly ITagAdminAppService _tagAdminAppService; + private ICurrentUser _currentUser; + private readonly CmsKitTestData _cmsKitTestData; + + public TagAdminAppService_Tests() + { + _tagAdminAppService = GetRequiredService(); + _cmsKitTestData = GetRequiredService(); + } + + protected override void AfterAddApplication(IServiceCollection services) + { + _currentUser = Substitute.For(); + services.AddSingleton(_currentUser); + } + + [Fact] + public async Task ShouldCreateProperly() + { + var list = await _tagAdminAppService.CreateAsync(new TagCreateDto + { + EntityType = "any_new_type", + Name = "1", + }); + + list.Id.ShouldNotBe(Guid.Empty); + } + + [Fact] + public async Task ShouldThrowException_WhenTagAlreadyExist() + { + await Should.ThrowAsync(async () => await _tagAdminAppService.CreateAsync(new TagCreateDto + { + EntityType = _cmsKitTestData.Content_1_EntityType, + Name = _cmsKitTestData.Content_1_Tags[0], + })); + } + } +} diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagPublicAppService_Tests.cs similarity index 95% rename from modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagAppService_Tests.cs rename to modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagPublicAppService_Tests.cs index 35b46b5a04..6ad1136167 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Tags/TagPublicAppService_Tests.cs @@ -10,13 +10,13 @@ using Xunit; namespace Volo.CmsKit.Tags { - public class TagAppService_Tests : CmsKitApplicationTestBase + public class TagPublicAppService_Tests : CmsKitApplicationTestBase { private readonly ITagAppService _tagAppService; private ICurrentUser _currentUser; private readonly CmsKitTestData _cmsKitTestData; - public TagAppService_Tests() + public TagPublicAppService_Tests() { _tagAppService = GetRequiredService(); _cmsKitTestData = GetRequiredService();