Browse Source

created tag test data and fix some bugs

pull/6858/head
Ahmet 6 years ago
parent
commit
c84aaf1e7b
  1. 2
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Contents/Content.cs
  2. 2
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/Page.cs
  3. 2
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTag.cs
  4. 2
      modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/Tag.cs
  5. 9
      modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Tags/TagRepository_Test.cs
  6. 11
      modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Tags/TagRepository_Test.cs
  7. 32
      modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitDataSeedContributor.cs
  8. 5
      modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs
  9. 3
      modules/cms-kit/test/Volo.CmsKit.TestBase/Contents/ContentRepository_Tests.cs
  10. 17
      modules/cms-kit/test/Volo.CmsKit.TestBase/Tags/TagRepository_Test.cs

2
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Contents/Content.cs

@ -8,7 +8,7 @@ namespace Volo.CmsKit.Contents
{ {
public class Content : FullAuditedAggregateRoot<Guid>, IMultiTenant public class Content : FullAuditedAggregateRoot<Guid>, IMultiTenant
{ {
public virtual Guid? TenantId { get; } public virtual Guid? TenantId { get; set; }
public virtual string EntityType { get; set; } public virtual string EntityType { get; set; }

2
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Pages/Page.cs

@ -8,7 +8,7 @@ namespace Volo.CmsKit.Pages
{ {
public class Page : FullAuditedAggregateRoot<Guid>, IMultiTenant public class Page : FullAuditedAggregateRoot<Guid>, IMultiTenant
{ {
public Guid? TenantId { get; } public Guid? TenantId { get; set; }
public virtual string Title { get; set; } public virtual string Title { get; set; }

2
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/EntityTag.cs

@ -10,7 +10,7 @@ namespace Volo.CmsKit.Tags
public virtual string EntityId { get; set; } public virtual string EntityId { get; set; }
public virtual Guid? TenantId { get; } public virtual Guid? TenantId { get; set; }
protected EntityTag() protected EntityTag()
{ {

2
modules/cms-kit/src/Volo.CmsKit.Domain/Volo/CmsKit/Tags/Tag.cs

@ -12,7 +12,7 @@ namespace Volo.CmsKit.Tags
public string Name { get; protected set; } public string Name { get; protected set; }
public Guid? TenantId { get; } public Guid? TenantId { get; set; }
protected Tag() protected Tag()
{ {

9
modules/cms-kit/test/Volo.CmsKit.EntityFrameworkCore.Tests/EntityFrameworkCore/Tags/TagRepository_Test.cs

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

11
modules/cms-kit/test/Volo.CmsKit.MongoDB.Tests/MongoDB/Tags/TagRepository_Test.cs

@ -0,0 +1,11 @@
using Volo.CmsKit.Tags;
using Xunit;
namespace Volo.CmsKit.MongoDB.Tags
{
[Collection(MongoTestCollection.Name)]
public class TagRepository_Test : TagRepository_Test<CmsKitMongoDbTestModule>
{
}
}

32
modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitDataSeedContributor.cs

@ -1,4 +1,5 @@
using System.Threading.Tasks; using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Data; using Volo.Abp.Data;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids; using Volo.Abp.Guids;
@ -8,6 +9,7 @@ using Volo.CmsKit.Comments;
using Volo.CmsKit.Contents; using Volo.CmsKit.Contents;
using Volo.CmsKit.Ratings; using Volo.CmsKit.Ratings;
using Volo.CmsKit.Reactions; using Volo.CmsKit.Reactions;
using Volo.CmsKit.Tags;
using Volo.CmsKit.Users; using Volo.CmsKit.Users;
namespace Volo.CmsKit namespace Volo.CmsKit
@ -22,6 +24,8 @@ namespace Volo.CmsKit
private readonly IRatingRepository _ratingRepository; private readonly IRatingRepository _ratingRepository;
private readonly ICurrentTenant _currentTenant; private readonly ICurrentTenant _currentTenant;
private readonly IContentRepository _contentRepository; private readonly IContentRepository _contentRepository;
private readonly ITagRepository _tagRepository;
public CmsKitDataSeedContributor( public CmsKitDataSeedContributor(
IGuidGenerator guidGenerator, IGuidGenerator guidGenerator,
ICmsUserRepository cmsUserRepository, ICmsUserRepository cmsUserRepository,
@ -30,7 +34,8 @@ namespace Volo.CmsKit
ReactionManager reactionManager, ReactionManager reactionManager,
IRatingRepository ratingRepository, IRatingRepository ratingRepository,
ICurrentTenant currentTenant, ICurrentTenant currentTenant,
IContentRepository contentRepository) IContentRepository contentRepository,
ITagRepository tagRepository)
{ {
_guidGenerator = guidGenerator; _guidGenerator = guidGenerator;
_cmsUserRepository = cmsUserRepository; _cmsUserRepository = cmsUserRepository;
@ -40,6 +45,7 @@ namespace Volo.CmsKit
_ratingRepository = ratingRepository; _ratingRepository = ratingRepository;
_currentTenant = currentTenant; _currentTenant = currentTenant;
_contentRepository = contentRepository; _contentRepository = contentRepository;
_tagRepository = tagRepository;
} }
public async Task SeedAsync(DataSeedContext context) public async Task SeedAsync(DataSeedContext context)
@ -55,6 +61,8 @@ namespace Volo.CmsKit
await SeedRatingsAsync(); await SeedRatingsAsync();
await SeedContentsAsync(); await SeedContentsAsync();
await SeedTagsAsync();
} }
} }
@ -202,5 +210,25 @@ namespace Volo.CmsKit
await _contentRepository.InsertAsync(content1); await _contentRepository.InsertAsync(content1);
await _contentRepository.InsertAsync(content2); await _contentRepository.InsertAsync(content2);
} }
private async Task SeedTagsAsync()
{
var content_1_tags =
_cmsKitTestData.Content_1_Tags
.Select(x =>
new Tag(_guidGenerator.Create(), _cmsKitTestData.Content_1_EntityType, x)).ToList();
var content_2_tags =
_cmsKitTestData.Content_2_Tags
.Select(x =>
new Tag(_guidGenerator.Create(), _cmsKitTestData.Content_2_EntityType, x)).ToList();
content_1_tags.AddRange(content_2_tags);
foreach (var tag in content_1_tags)
{
await _tagRepository.InsertAsync(tag);
}
}
} }
} }

5
modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestData.cs

@ -1,4 +1,5 @@
using System; using System;
using JetBrains.Annotations;
using Volo.Abp.DependencyInjection; using Volo.Abp.DependencyInjection;
namespace Volo.CmsKit namespace Volo.CmsKit
@ -24,11 +25,15 @@ namespace Volo.CmsKit
public string Content_1 { get; } = "First things first\nI'ma say all the words inside my head\nI'm fired up and tired of the way that things have been, oh-ooh\nThe way that things have been, oh-ooh"; public string Content_1 { get; } = "First things first\nI'ma say all the words inside my head\nI'm fired up and tired of the way that things have been, oh-ooh\nThe way that things have been, oh-ooh";
public string Content_1_Id = "1"; public string Content_1_Id = "1";
public string[] Content_1_Tags => new string[] {"Imagine Dragons", "Music"};
public string Content_2_EntityType = "LyricsAlso"; public string Content_2_EntityType = "LyricsAlso";
public string Content_2 { get; } = "Second thing second\nDon't you tell me what you think that I could be\nI'm the one at the sail, I'm the master of my sea, oh-ooh\nThe master of my sea, oh-ooh"; public string Content_2 { get; } = "Second thing second\nDon't you tell me what you think that I could be\nI'm the one at the sail, I'm the master of my sea, oh-ooh\nThe master of my sea, oh-ooh";
public string Content_2_Id = "2"; public string Content_2_Id = "2";
public string[] Content_2_Tags => new string[] {"Imagine Dragons", "Music", "Most Loved Part"};
} }
} }

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

@ -3,7 +3,6 @@ using System.Threading.Tasks;
using Shouldly; using Shouldly;
using Volo.Abp.Domain.Entities; using Volo.Abp.Domain.Entities;
using Volo.Abp.Modularity; using Volo.Abp.Modularity;
using Volo.Abp.Uow;
using Xunit; using Xunit;
namespace Volo.CmsKit.Contents namespace Volo.CmsKit.Contents
@ -14,7 +13,7 @@ namespace Volo.CmsKit.Contents
private readonly CmsKitTestData _cmsKitTestData; private readonly CmsKitTestData _cmsKitTestData;
private readonly IContentRepository _contentRepository; private readonly IContentRepository _contentRepository;
public ContentRepository_Tests() protected ContentRepository_Tests()
{ {
_cmsKitTestData = GetRequiredService<CmsKitTestData>(); _cmsKitTestData = GetRequiredService<CmsKitTestData>();
_contentRepository = GetRequiredService<IContentRepository>(); _contentRepository = GetRequiredService<IContentRepository>();

17
modules/cms-kit/test/Volo.CmsKit.TestBase/Tags/TagRepository_Test.cs

@ -0,0 +1,17 @@
using Volo.Abp.Modularity;
namespace Volo.CmsKit.Tags
{
public abstract class TagRepository_Test<TStartupModule> : CmsKitTestBase<TStartupModule>
where TStartupModule : IAbpModule
{
private readonly CmsKitTestData _cmsKitTestData;
private readonly ITagRepository _tagRepository;
protected TagRepository_Test()
{
_cmsKitTestData = GetRequiredService<CmsKitTestData>();
_tagRepository = GetRequiredService<ITagRepository>();
}
}
}
Loading…
Cancel
Save