CmsKit - BlogFeature public tests

pull/7745/head
enisn 5 years ago
parent e71051b15c
commit c56189a8b2

@ -5,13 +5,13 @@ using Xunit;
namespace Volo.CmsKit.Blogs
{
public class BlogFeatureAdminAppService : CmsKitApplicationTestBase
public class BlogFeatureAdminAppService_Test : CmsKitApplicationTestBase
{
private readonly CmsKitTestData testData;
private readonly IBlogFeatureAdminAppService blogFeatureAdminAppService;
private readonly IBlogFeatureRepository blogFeatureRepository;
public BlogFeatureAdminAppService()
public BlogFeatureAdminAppService_Test()
{
testData = GetRequiredService<CmsKitTestData>();
blogFeatureAdminAppService = GetRequiredService<IBlogFeatureAdminAppService>();

@ -0,0 +1,43 @@
using Shouldly;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Volo.CmsKit.Public.Blogs;
using Xunit;
namespace Volo.CmsKit.Blogs
{
public class BlogFeaturePublicAppService_Test : CmsKitApplicationTestBase
{
private readonly CmsKitTestData testData;
private readonly IBlogFeaturePublicAppService blogFeaturePublicAppService;
public BlogFeaturePublicAppService_Test()
{
testData = GetRequiredService<CmsKitTestData>();
blogFeaturePublicAppService = GetRequiredService<IBlogFeaturePublicAppService>();
}
[Fact]
public async Task GetAsync_ShouldWorkProperly_WithExistingFeatureName()
{
var result = await blogFeaturePublicAppService.GetAsync(testData.Blog_Id, testData.BlogFeature_1_FeatureName);
result.ShouldNotBeNull();
result.FeatureName.ShouldBe(testData.BlogFeature_1_FeatureName);
}
[Fact]
public async Task GetAsync_ShouldReturnDefault_WithNonExistingFeatureName()
{
var nonExistingFeatureName = "AnyOtherFeature";
var result = await blogFeaturePublicAppService.GetAsync(testData.Blog_Id, nonExistingFeatureName);
var defaultFeature = new BlogFeature(Guid.Empty, nonExistingFeatureName);
result.ShouldNotBeNull();
result.Enabled.ShouldBe(defaultFeature.Enabled);
}
}
}

@ -27,6 +27,16 @@ namespace Volo.CmsKit.Blogs
result.Count.ShouldBe(2);
}
[Fact]
public async Task GetListAsync_ShouldWorkProperly_WithBlogIdWithFeatureNames()
{
var result = await blogFeatureRepository.GetListAsync(testData.Blog_Id, new[] { testData.BlogFeature_1_FeatureName });
result.ShouldNotBeNull();
result.ShouldNotBeEmpty();
result.Count.ShouldBe(1);
}
[Fact]
public async Task FindAsync_ShouldWorkProperly_WithExistingFeatureName()
{

Loading…
Cancel
Save