mirror of https://github.com/abpframework/abp.git
3 changed files with 84 additions and 0 deletions
@ -0,0 +1,9 @@ |
|||||
|
using Volo.CmsKit.Contents; |
||||
|
|
||||
|
namespace Volo.CmsKit.EntityFrameworkCore.Contents |
||||
|
{ |
||||
|
public class ContentRepository_Test : ContentRepository_Tests<CmsKitEntityFrameworkCoreTestModule> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,11 @@ |
|||||
|
using Volo.CmsKit.Contents; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.CmsKit.MongoDB.Contents |
||||
|
{ |
||||
|
[Collection(MongoTestCollection.Name)] |
||||
|
public class ContentRepository_Test : ContentRepository_Tests<CmsKitMongoDbTestModule> |
||||
|
{ |
||||
|
|
||||
|
} |
||||
|
} |
||||
@ -0,0 +1,64 @@ |
|||||
|
using System; |
||||
|
using System.Threading.Tasks; |
||||
|
using Shouldly; |
||||
|
using Volo.Abp.Domain.Entities; |
||||
|
using Volo.Abp.Modularity; |
||||
|
using Volo.Abp.Uow; |
||||
|
using Xunit; |
||||
|
|
||||
|
namespace Volo.CmsKit.Contents |
||||
|
{ |
||||
|
public abstract class ContentRepository_Tests<TStartupModule> : CmsKitTestBase<TStartupModule> |
||||
|
where TStartupModule : IAbpModule |
||||
|
{ |
||||
|
private readonly CmsKitTestData _cmsKitTestData; |
||||
|
private readonly IContentRepository _contentRepository; |
||||
|
|
||||
|
public ContentRepository_Tests() |
||||
|
{ |
||||
|
_cmsKitTestData = GetRequiredService<CmsKitTestData>(); |
||||
|
_contentRepository = GetRequiredService<IContentRepository>(); |
||||
|
} |
||||
|
|
||||
|
[Theory] |
||||
|
[InlineData("Lyrics", "1", "First things first")] |
||||
|
[InlineData("LyricsAlso", "2", "Second thing second")] |
||||
|
public async Task ShouldGetAsync(string entityType, string entityId, string contentStartsWith = null) |
||||
|
{ |
||||
|
var content = await _contentRepository.GetAsync(entityType, entityId); |
||||
|
|
||||
|
content.ShouldNotBeNull(); |
||||
|
|
||||
|
if (contentStartsWith != null) |
||||
|
{ |
||||
|
content.Value.ShouldStartWith(contentStartsWith); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task ShouldNotGetAsync() |
||||
|
{ |
||||
|
Should.Throw<EntityNotFoundException>( |
||||
|
async () |
||||
|
=> |
||||
|
await _contentRepository.GetAsync("not_exist_entity", Guid.NewGuid().ToString())); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task ShouldFindAsync() |
||||
|
{ |
||||
|
var content = |
||||
|
await _contentRepository.FindAsync(_cmsKitTestData.Content_1_EntityType, _cmsKitTestData.Content_1_Id); |
||||
|
|
||||
|
content.ShouldNotBeNull(); |
||||
|
} |
||||
|
|
||||
|
[Fact] |
||||
|
public async Task ShouldNotFindAsync() |
||||
|
{ |
||||
|
var content = await _contentRepository.FindAsync("not_exist_entity", Guid.NewGuid().ToString()); |
||||
|
|
||||
|
content.ShouldBeNull(); |
||||
|
} |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue