created tag test data and fix some bugs

pull/6858/head
Ahmet 5 years ago
parent dfe9ea40dd
commit c84aaf1e7b

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

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

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

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

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

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

@ -1,4 +1,5 @@
using System.Threading.Tasks;
using System.Linq;
using System.Threading.Tasks;
using Volo.Abp.Data;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Guids;
@ -8,6 +9,7 @@ using Volo.CmsKit.Comments;
using Volo.CmsKit.Contents;
using Volo.CmsKit.Ratings;
using Volo.CmsKit.Reactions;
using Volo.CmsKit.Tags;
using Volo.CmsKit.Users;
namespace Volo.CmsKit
@ -22,6 +24,8 @@ namespace Volo.CmsKit
private readonly IRatingRepository _ratingRepository;
private readonly ICurrentTenant _currentTenant;
private readonly IContentRepository _contentRepository;
private readonly ITagRepository _tagRepository;
public CmsKitDataSeedContributor(
IGuidGenerator guidGenerator,
ICmsUserRepository cmsUserRepository,
@ -30,7 +34,8 @@ namespace Volo.CmsKit
ReactionManager reactionManager,
IRatingRepository ratingRepository,
ICurrentTenant currentTenant,
IContentRepository contentRepository)
IContentRepository contentRepository,
ITagRepository tagRepository)
{
_guidGenerator = guidGenerator;
_cmsUserRepository = cmsUserRepository;
@ -40,6 +45,7 @@ namespace Volo.CmsKit
_ratingRepository = ratingRepository;
_currentTenant = currentTenant;
_contentRepository = contentRepository;
_tagRepository = tagRepository;
}
public async Task SeedAsync(DataSeedContext context)
@ -55,6 +61,8 @@ namespace Volo.CmsKit
await SeedRatingsAsync();
await SeedContentsAsync();
await SeedTagsAsync();
}
}
@ -202,5 +210,25 @@ namespace Volo.CmsKit
await _contentRepository.InsertAsync(content1);
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);
}
}
}
}

@ -1,4 +1,5 @@
using System;
using JetBrains.Annotations;
using Volo.Abp.DependencyInjection;
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_Id = "1";
public string[] Content_1_Tags => new string[] {"Imagine Dragons", "Music"};
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_Id = "2";
public string[] Content_2_Tags => new string[] {"Imagine Dragons", "Music", "Most Loved Part"};
}
}

@ -3,7 +3,6 @@ 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
@ -14,7 +13,7 @@ namespace Volo.CmsKit.Contents
private readonly CmsKitTestData _cmsKitTestData;
private readonly IContentRepository _contentRepository;
public ContentRepository_Tests()
protected ContentRepository_Tests()
{
_cmsKitTestData = GetRequiredService<CmsKitTestData>();
_contentRepository = GetRequiredService<IContentRepository>();

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