From 1b3b596eb0118dfc7b37b7cbbf47f08a378bea81 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Thu, 13 Aug 2020 18:11:19 +0300 Subject: [PATCH] Added "features" to the CMS kit and implemented on the EF Core layer. --- .../FeatureConfigurer.cs | 10 ++++ .../Volo.CmsKit.Host.Shared.csproj | 4 ++ .../CmsKitHttpApiHostModule.cs | 7 ++- ...itHttpApiHostMigrationsDbContextFactory.cs | 2 + .../CmsKitIdentityServerModule.cs | 9 ++- ...ityServerHostMigrationsDbContextFactory.cs | 2 + .../CmsKitWebHostModule.cs | 4 +- .../CmsKitWebUnifiedModule.cs | 5 ++ .../UnifiedDbContextFactory.cs | 2 + .../Volo/CmsKit/CmsKitFeatures.cs | 56 +++++++++++++++++++ .../Volo/CmsKit/GlobalFeatures.cs | 42 ++++++++++++++ .../Comments/EfCoreCommentRepository.cs | 3 +- .../EntityFrameworkCore/CmsKitDbContext.cs | 9 --- .../CmsKitDbContextModelCreatingExtensions.cs | 48 +++++++++------- .../EntityFrameworkCore/ICmsKitDbContext.cs | 11 +--- .../Comments/CommentPublicAppService_Tests.cs | 11 ++-- .../ReactionPublicAppService_Tests.cs | 9 +-- .../Reactions/ReactionManager_Tests.cs | 2 +- .../CmsKitTestBaseModule.cs | 2 + 19 files changed, 179 insertions(+), 59 deletions(-) create mode 100644 modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitFeatures.cs create mode 100644 modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures.cs diff --git a/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs b/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs new file mode 100644 index 0000000000..3d4d983f3b --- /dev/null +++ b/modules/cms-kit/host/Volo.CmsKit.Host.Shared/FeatureConfigurer.cs @@ -0,0 +1,10 @@ +namespace Volo.CmsKit +{ + public static class FeatureConfigurer + { + public static void Configure() + { + CmsKitFeatures.EnableAll(); + } + } +} diff --git a/modules/cms-kit/host/Volo.CmsKit.Host.Shared/Volo.CmsKit.Host.Shared.csproj b/modules/cms-kit/host/Volo.CmsKit.Host.Shared/Volo.CmsKit.Host.Shared.csproj index 3f8c167b98..c6a4484865 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Host.Shared/Volo.CmsKit.Host.Shared.csproj +++ b/modules/cms-kit/host/Volo.CmsKit.Host.Shared/Volo.CmsKit.Host.Shared.csproj @@ -7,4 +7,8 @@ Volo.CmsKit + + + + diff --git a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/CmsKitHttpApiHostModule.cs b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/CmsKitHttpApiHostModule.cs index c63d28081f..f1a9b8568f 100644 --- a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/CmsKitHttpApiHostModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/CmsKitHttpApiHostModule.cs @@ -52,6 +52,11 @@ namespace Volo.CmsKit { private const string DefaultCorsPolicyName = "Default"; + public override void PreConfigureServices(ServiceConfigurationContext context) + { + FeatureConfigurer.Configure(); + } + public override void ConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); @@ -163,7 +168,7 @@ namespace Volo.CmsKit app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); - app.UseCors(DefaultCorsPolicyName); + app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); app.UseAbpClaimsMap(); if (MultiTenancyConsts.IsEnabled) diff --git a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContextFactory.cs b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContextFactory.cs index 3a6dbb47ad..dc19e09635 100644 --- a/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContextFactory.cs +++ b/modules/cms-kit/host/Volo.CmsKit.HttpApi.Host/EntityFrameworkCore/CmsKitHttpApiHostMigrationsDbContextFactory.cs @@ -9,6 +9,8 @@ namespace Volo.CmsKit.EntityFrameworkCore { public CmsKitHttpApiHostMigrationsDbContext CreateDbContext(string[] args) { + FeatureConfigurer.Configure(); + var configuration = BuildConfiguration(); var builder = new DbContextOptionsBuilder() diff --git a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/CmsKitIdentityServerModule.cs b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/CmsKitIdentityServerModule.cs index faf90a3fc2..b9afe934a3 100644 --- a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/CmsKitIdentityServerModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/CmsKitIdentityServerModule.cs @@ -77,6 +77,11 @@ namespace Volo.CmsKit { private const string DefaultCorsPolicyName = "Default"; + public override void PreConfigureServices(ServiceConfigurationContext context) + { + FeatureConfigurer.Configure(); + } + public override void ConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); @@ -182,10 +187,10 @@ namespace Volo.CmsKit app.UseCorrelationId(); app.UseVirtualFiles(); app.UseRouting(); - app.UseCors(DefaultCorsPolicyName); + app.UseCors(DefaultCorsPolicyName); app.UseAuthentication(); app.UseJwtTokenMiddleware(); - + if (MultiTenancyConsts.IsEnabled) { app.UseMultiTenancy(); diff --git a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs index f6e80d62ec..19402b80c1 100644 --- a/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs +++ b/modules/cms-kit/host/Volo.CmsKit.IdentityServer/EntityFrameworkCore/IdentityServerHostMigrationsDbContextFactory.cs @@ -9,6 +9,8 @@ namespace Volo.CmsKit.EntityFrameworkCore { public IdentityServerHostMigrationsDbContext CreateDbContext(string[] args) { + FeatureConfigurer.Configure(); + var configuration = BuildConfiguration(); var builder = new DbContextOptionsBuilder() diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostModule.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostModule.cs index 95946c54df..7587b075d0 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Host/CmsKitWebHostModule.cs @@ -65,6 +65,8 @@ namespace Volo.CmsKit { public override void PreConfigureServices(ServiceConfigurationContext context) { + FeatureConfigurer.Configure(); + context.Services.PreConfigure(options => { options.AddAssemblyResource( @@ -222,7 +224,7 @@ namespace Volo.CmsKit app.UseHttpsRedirection(); app.UseVirtualFiles(); app.UseRouting(); - app.UseAuthentication(); + app.UseAuthentication(); if (MultiTenancyConsts.IsEnabled) { diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs index b1cd636ef0..08dadb3dd6 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/CmsKitWebUnifiedModule.cs @@ -63,6 +63,11 @@ namespace Volo.CmsKit )] public class CmsKitWebUnifiedModule : AbpModule { + public override void PreConfigureServices(ServiceConfigurationContext context) + { + FeatureConfigurer.Configure(); + } + public override void ConfigureServices(ServiceConfigurationContext context) { var hostingEnvironment = context.Services.GetHostingEnvironment(); diff --git a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs index f2c1d8a065..170e4dc688 100644 --- a/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs +++ b/modules/cms-kit/host/Volo.CmsKit.Web.Unified/EntityFrameworkCore/UnifiedDbContextFactory.cs @@ -9,6 +9,8 @@ namespace Volo.CmsKit.EntityFrameworkCore { public UnifiedDbContext CreateDbContext(string[] args) { + FeatureConfigurer.Configure(); + var configuration = BuildConfiguration(); var builder = new DbContextOptionsBuilder() diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitFeatures.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitFeatures.cs new file mode 100644 index 0000000000..6e9dff0011 --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/CmsKitFeatures.cs @@ -0,0 +1,56 @@ +using System.Collections.Generic; + +namespace Volo.CmsKit +{ + public static class CmsKitFeatures + { + public const string NamePrefix = "CmsKit"; + + public static class Reactions + { + public const string Name = NamePrefix + ".Reactions"; + + public static bool IsEnabled + { + get => GlobalFeatures.IsEnabled(Name); + set => GlobalFeatures.SetEnabled(Name, value); + } + } + + public static class Comments + { + public const string Name = NamePrefix + ".Comments"; + + public static bool IsEnabled + { + get => GlobalFeatures.IsEnabled(Name); + set => GlobalFeatures.SetEnabled(Name, value); + } + } + + public static void EnableAll() + { + foreach (var featureName in GetAllNames()) + { + GlobalFeatures.Enable(featureName); + } + } + + public static void DisableAll() + { + foreach (var featureName in GetAllNames()) + { + GlobalFeatures.Disable(featureName); + } + } + + public static IEnumerable GetAllNames() + { + return new[] + { + Reactions.Name, + Comments.Name + }; + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures.cs b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures.cs new file mode 100644 index 0000000000..3c038431ca --- /dev/null +++ b/modules/cms-kit/src/Volo.CmsKit.Domain.Shared/Volo/CmsKit/GlobalFeatures.cs @@ -0,0 +1,42 @@ +using System.Collections.Generic; +using System.Linq; + +namespace Volo.CmsKit +{ + internal static class GlobalFeatures //TODO: Move to the ABP Framework..? + { + private static readonly HashSet EnabledFeatures = new HashSet(); + + public static bool IsEnabled(string featureName) + { + return EnabledFeatures.Contains(featureName); + } + + public static void SetEnabled(string featureName, bool isEnabled) + { + if (isEnabled) + { + Enable(featureName); + } + else + { + Disable(featureName); + } + } + + public static void Enable(string featureName) + { + EnabledFeatures.AddIfNotContains(featureName); + } + + public static void Disable(string featureName) + { + EnabledFeatures.Remove(featureName); + } + + public static IEnumerable GetEnabledFeatures() + { + return EnabledFeatures; + } + } +} diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs index 00b3150219..6a1b8d6a50 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/Comments/EfCoreCommentRepository.cs @@ -8,6 +8,7 @@ using Volo.Abp; using Volo.Abp.Domain.Repositories.EntityFrameworkCore; using Volo.Abp.EntityFrameworkCore; using Volo.CmsKit.EntityFrameworkCore; +using Volo.CmsKit.Users; namespace Volo.CmsKit.Comments { @@ -27,7 +28,7 @@ namespace Volo.CmsKit.Comments Check.NotNullOrWhiteSpace(entityId, nameof(entityId)); var query = from comment in DbSet - join user in DbContext.CmsUsers on comment.CreatorId equals user.Id + join user in DbContext.Set() on comment.CreatorId equals user.Id where entityType == comment.EntityType && entityId == comment.EntityId orderby comment.CreationTime select new CommentWithAuthorQueryResultItem diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContext.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContext.cs index 8033522f70..65d9b55181 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContext.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContext.cs @@ -1,21 +1,12 @@ using Microsoft.EntityFrameworkCore; using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; -using Volo.CmsKit.Comments; -using Volo.CmsKit.Reactions; -using Volo.CmsKit.Users; namespace Volo.CmsKit.EntityFrameworkCore { [ConnectionStringName(CmsKitDbProperties.ConnectionStringName)] public class CmsKitDbContext : AbpDbContext, ICmsKitDbContext { - public DbSet UserReactions { get; set; } - - public DbSet Comments { get; set; } - - public DbSet CmsUsers { get; set; } - public CmsKitDbContext(DbContextOptions options) : base(options) { diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs index e945ddc7ed..d778f43f57 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/CmsKitDbContextModelCreatingExtensions.cs @@ -32,34 +32,40 @@ namespace Volo.CmsKit.EntityFrameworkCore b.ConfigureAbpUser(); }); - builder.Entity(b => + if (CmsKitFeatures.Reactions.IsEnabled) { - b.ToTable(options.TablePrefix + "UserReactions", options.Schema); - b.ConfigureByConvention(); + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "UserReactions", options.Schema); + b.ConfigureByConvention(); - b.Property(x => x.EntityType).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityTypeLength); - b.Property(x => x.EntityId).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityIdLength); - b.Property(x => x.ReactionName).IsRequired().HasMaxLength(UserReactionConsts.MaxReactionNameLength); - b.Property(x => x.CreationTime); + b.Property(x => x.EntityType).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityTypeLength); + b.Property(x => x.EntityId).IsRequired().HasMaxLength(UserReactionConsts.MaxEntityIdLength); + b.Property(x => x.ReactionName).IsRequired().HasMaxLength(UserReactionConsts.MaxReactionNameLength); + b.Property(x => x.CreationTime); - b.HasIndex(x => new { x.EntityType, x.EntityId }); - b.HasIndex(x => new { x.CreatorId, x.EntityType, x.EntityId, x.ReactionName }); - }); + b.HasIndex(x => new { x.EntityType, x.EntityId }); + b.HasIndex(x => new { x.CreatorId, x.EntityType, x.EntityId, x.ReactionName }); + }); + } - builder.Entity(b => + if (CmsKitFeatures.Comments.IsEnabled) { - b.ToTable(options.TablePrefix + "Comments", options.Schema); - b.ConfigureByConvention(); + builder.Entity(b => + { + b.ToTable(options.TablePrefix + "Comments", options.Schema); + b.ConfigureByConvention(); - b.Property(x => x.EntityType).IsRequired().HasMaxLength(CommentConsts.MaxEntityTypeLength); - b.Property(x => x.EntityId).IsRequired().HasMaxLength(CommentConsts.MaxEntityIdLength); - b.Property(x => x.Text).IsRequired().HasMaxLength(CommentConsts.MaxTextLength); - b.Property(x => x.RepliedCommentId); - b.Property(x => x.CreationTime); + b.Property(x => x.EntityType).IsRequired().HasMaxLength(CommentConsts.MaxEntityTypeLength); + b.Property(x => x.EntityId).IsRequired().HasMaxLength(CommentConsts.MaxEntityIdLength); + b.Property(x => x.Text).IsRequired().HasMaxLength(CommentConsts.MaxTextLength); + b.Property(x => x.RepliedCommentId); + b.Property(x => x.CreationTime); - b.HasIndex(x => new { x.EntityType, x.EntityId }); - b.HasIndex(x => new { x.RepliedCommentId }); - }); + b.HasIndex(x => new { x.EntityType, x.EntityId }); + b.HasIndex(x => new { x.RepliedCommentId }); + }); + } } } } diff --git a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/ICmsKitDbContext.cs b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/ICmsKitDbContext.cs index e63366d5ae..352335fb7c 100644 --- a/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/ICmsKitDbContext.cs +++ b/modules/cms-kit/src/Volo.CmsKit.EntityFrameworkCore/Volo/CmsKit/EntityFrameworkCore/ICmsKitDbContext.cs @@ -1,19 +1,10 @@ -using Microsoft.EntityFrameworkCore; -using Volo.Abp.Data; +using Volo.Abp.Data; using Volo.Abp.EntityFrameworkCore; -using Volo.CmsKit.Comments; -using Volo.CmsKit.Reactions; -using Volo.CmsKit.Users; namespace Volo.CmsKit.EntityFrameworkCore { [ConnectionStringName(CmsKitDbProperties.ConnectionStringName)] public interface ICmsKitDbContext : IEfCoreDbContext { - DbSet UserReactions { get; } - - DbSet Comments { get; } - - DbSet CmsUsers { get; set; } } } diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentPublicAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentPublicAppService_Tests.cs index 9568f79c6f..f02339dde8 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentPublicAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Comments/CommentPublicAppService_Tests.cs @@ -1,11 +1,8 @@ -using System; -using System.Linq; +using System.Linq; using System.Threading.Tasks; -using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using NSubstitute; using Shouldly; -using Volo.Abp.MultiTenancy; using Volo.Abp.Users; using Volo.CmsKit.Public.Comments; using Xunit; @@ -54,7 +51,7 @@ namespace Volo.CmsKit.Comments UsingDbContext(context => { - var comments = context.Comments.Where(x => + var comments = context.Set().Where(x => x.EntityId == _cmsKitTestData.EntityId1 && x.EntityType == _cmsKitTestData.EntityType1).ToList(); comments @@ -75,7 +72,7 @@ namespace Volo.CmsKit.Comments UsingDbContext(context => { - var comment = context.Comments.Single(x => + var comment = context.Set().Single(x => x.Id == _cmsKitTestData.CommentWithChildId); comment.Text.ShouldBe("I'm Updated"); @@ -91,7 +88,7 @@ namespace Volo.CmsKit.Comments UsingDbContext(context => { - var comment = context.Comments.FirstOrDefault(x => + var comment = context.Set().FirstOrDefault(x => x.Id == _cmsKitTestData.CommentWithChildId); comment.ShouldBeNull(); diff --git a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs index dd74a1f1e7..615003efec 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Application.Tests/Reactions/ReactionPublicAppService_Tests.cs @@ -1,7 +1,4 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; +using System.Linq; using System.Threading.Tasks; using Microsoft.Extensions.DependencyInjection; using NSubstitute; @@ -69,7 +66,7 @@ namespace Volo.CmsKit.Reactions UsingDbContext(context => { - var reaction = context.UserReactions.FirstOrDefault(x => + var reaction = context.Set().FirstOrDefault(x => x.CreatorId == _cmsKitTestData.User1Id && x.ReactionName == StandardReactions.Hooray && x.EntityId == _cmsKitTestData.EntityId2 && @@ -93,7 +90,7 @@ namespace Volo.CmsKit.Reactions UsingDbContext(context => { - var reaction = context.UserReactions.FirstOrDefault(x => + var reaction = context.Set().FirstOrDefault(x => x.CreatorId == _cmsKitTestData.User1Id && x.ReactionName == StandardReactions.Confused && x.EntityId == _cmsKitTestData.EntityId1 && diff --git a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Reactions/ReactionManager_Tests.cs b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Reactions/ReactionManager_Tests.cs index 6f4fe2425d..453d393bb8 100644 --- a/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Reactions/ReactionManager_Tests.cs +++ b/modules/cms-kit/test/Volo.CmsKit.Domain.Tests/Reactions/ReactionManager_Tests.cs @@ -69,7 +69,7 @@ namespace Volo.CmsKit.Reactions UsingDbContext(context => { - var reaction = context.UserReactions.FirstOrDefault(x => + var reaction = context.Set().FirstOrDefault(x => x.CreatorId == _cmsKitTestData.User1Id && x.ReactionName == StandardReactions.Confused && x.EntityId == _cmsKitTestData.EntityId1 && diff --git a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs index ae1f0f7296..7451c755a8 100644 --- a/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs +++ b/modules/cms-kit/test/Volo.CmsKit.TestBase/CmsKitTestBaseModule.cs @@ -18,6 +18,8 @@ namespace Volo.CmsKit { public override void ConfigureServices(ServiceConfigurationContext context) { + CmsKitFeatures.EnableAll(); + context.Services.AddAlwaysAllowAuthorization(); }