Browse Source

Added content repository tests

pull/6858/head
Ahmet 6 years ago
parent
commit
055a7a91c8
  1. 9
      modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Contents/ContentRepository_Test.cs
  2. 11
      modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Contents/ContentRepository_Test.cs
  3. 64
      modules/cms-kit/test/Volo.CmsKit.TestBase/Contents/ContentRepository_Tests.cs

9
modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Contents/ContentRepository_Test.cs

@ -0,0 +1,9 @@
using Volo.CmsKit.Contents;
namespace Volo.CmsKit.EntityFrameworkCore.Contents
{
public class ContentRepository_Test : ContentRepository_Tests<CmsKitEntityFrameworkCoreTestModule>
{
}
}

11
modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Contents/ContentRepository_Test.cs

@ -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>
{
}
}

64
modules/cms-kit/test/Volo.CmsKit.TestBase/Contents/ContentRepository_Tests.cs

@ -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…
Cancel
Save