From a93de36f5b44c3ef3aeb46eaca8444cf7fb4eb9d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Halil=20=C4=B0brahim=20Kalkan?= Date: Mon, 8 May 2017 13:11:29 +0300 Subject: [PATCH] Move AbpInterceptionTestBase to Volo.Abp.Tests since it's independent from Castle.Core. --- .../Volo.Abp.Autofac.Tests.csproj | 2 +- .../Volo/Abp/Autofac/AutofacTestModule.cs | 4 +-- .../Interception/Autofac_Interception_Test.cs | 3 +- .../Volo.Abp.Castle.Core.Tests.csproj | 4 +++ .../Abp/Castle/AbpCastleCoreTestModule.cs | 31 ------------------- .../DynamicProxy/AbpInterceptionTestBase.cs} | 24 ++++++++++++-- .../DynamicProxy/SimpleAsyncInterceptor.cs | 5 ++- .../DynamicProxy/SimpleAsyncInterceptor2.cs | 2 +- .../SimpleInterceptionTargetClass.cs | 5 ++- .../DynamicProxy/SimpleSyncInterceptor.cs | 5 ++- 10 files changed, 36 insertions(+), 49 deletions(-) delete mode 100644 test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/AbpCastleCoreTestModule.cs rename test/{Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/CastleInterceptionTestBase.cs => Volo.Abp.Tests/Volo/Abp/DynamicProxy/AbpInterceptionTestBase.cs} (81%) rename test/{Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle => Volo.Abp.Tests/Volo/Abp}/DynamicProxy/SimpleAsyncInterceptor.cs (86%) rename test/{Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle => Volo.Abp.Tests/Volo/Abp}/DynamicProxy/SimpleAsyncInterceptor2.cs (64%) rename test/{Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle => Volo.Abp.Tests/Volo/Abp}/DynamicProxy/SimpleInterceptionTargetClass.cs (85%) rename test/{Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle => Volo.Abp.Tests/Volo/Abp}/DynamicProxy/SimpleSyncInterceptor.cs (72%) diff --git a/test/Volo.Abp.Autofac.Tests/Volo.Abp.Autofac.Tests.csproj b/test/Volo.Abp.Autofac.Tests/Volo.Abp.Autofac.Tests.csproj index cb305a458d..f7e4807ee7 100644 --- a/test/Volo.Abp.Autofac.Tests/Volo.Abp.Autofac.Tests.csproj +++ b/test/Volo.Abp.Autofac.Tests/Volo.Abp.Autofac.Tests.csproj @@ -15,7 +15,7 @@ - + diff --git a/test/Volo.Abp.Autofac.Tests/Volo/Abp/Autofac/AutofacTestModule.cs b/test/Volo.Abp.Autofac.Tests/Volo/Abp/Autofac/AutofacTestModule.cs index 12d06b5c38..d6e73edf4f 100644 --- a/test/Volo.Abp.Autofac.Tests/Volo/Abp/Autofac/AutofacTestModule.cs +++ b/test/Volo.Abp.Autofac.Tests/Volo/Abp/Autofac/AutofacTestModule.cs @@ -1,11 +1,9 @@ using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.Castle; -using Volo.Abp.Castle.DynamicProxy; using Volo.Abp.Modularity; namespace Volo.Abp.Autofac { - [DependsOn(typeof(AbpAutofacModule), typeof(AbpCastleCoreTestModule))] + [DependsOn(typeof(AbpAutofacModule))] public class AutofacTestModule : AbpModule { public override void ConfigureServices(IServiceCollection services) diff --git a/test/Volo.Abp.Autofac.Tests/Volo/Abp/Autofac/Interception/Autofac_Interception_Test.cs b/test/Volo.Abp.Autofac.Tests/Volo/Abp/Autofac/Interception/Autofac_Interception_Test.cs index 9c891562ce..6dc5847ec7 100644 --- a/test/Volo.Abp.Autofac.Tests/Volo/Abp/Autofac/Interception/Autofac_Interception_Test.cs +++ b/test/Volo.Abp.Autofac.Tests/Volo/Abp/Autofac/Interception/Autofac_Interception_Test.cs @@ -1,10 +1,11 @@ using System; using Microsoft.Extensions.DependencyInjection; using Volo.Abp.Castle.DynamicProxy; +using Volo.Abp.DynamicProxy; namespace Volo.Abp.Autofac.Interception { - public class Autofac_Interception_Test : CastleInterceptionTestBase + public class Autofac_Interception_Test : AbpInterceptionTestBase { //TODO: Sımplify using autofac in tests! diff --git a/test/Volo.Abp.Castle.Core.Tests/Volo.Abp.Castle.Core.Tests.csproj b/test/Volo.Abp.Castle.Core.Tests/Volo.Abp.Castle.Core.Tests.csproj index 4fc2425f21..61586465c9 100644 --- a/test/Volo.Abp.Castle.Core.Tests/Volo.Abp.Castle.Core.Tests.csproj +++ b/test/Volo.Abp.Castle.Core.Tests/Volo.Abp.Castle.Core.Tests.csproj @@ -21,4 +21,8 @@ + + + + \ No newline at end of file diff --git a/test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/AbpCastleCoreTestModule.cs b/test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/AbpCastleCoreTestModule.cs deleted file mode 100644 index c47a138f5b..0000000000 --- a/test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/AbpCastleCoreTestModule.cs +++ /dev/null @@ -1,31 +0,0 @@ -using Microsoft.Extensions.DependencyInjection; -using Volo.Abp.Castle.DynamicProxy; -using Volo.Abp.Modularity; - -namespace Volo.Abp.Castle -{ - [DependsOn(typeof(AbpCastleCoreModule))] - public class AbpCastleCoreTestModule : AbpModule - { - public override void PreConfigureServices(IServiceCollection services) - { - services.OnServiceRegistred(RegisterTestInterceptors); - } - - public override void ConfigureServices(IServiceCollection services) - { - services.AddAssemblyOf(); - } - - private static void RegisterTestInterceptors(IOnServiceRegistredArgs registration) - { - //TODO: Create an attribute to add interceptors! - if (typeof(SimpleInterceptionTargetClass) == registration.ImplementationType) - { - registration.Interceptors.Add(); - registration.Interceptors.Add(); - registration.Interceptors.Add(); - } - } - } -} diff --git a/test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/CastleInterceptionTestBase.cs b/test/Volo.Abp.Tests/Volo/Abp/DynamicProxy/AbpInterceptionTestBase.cs similarity index 81% rename from test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/CastleInterceptionTestBase.cs rename to test/Volo.Abp.Tests/Volo/Abp/DynamicProxy/AbpInterceptionTestBase.cs index cccb5a8b67..6e1fab17ae 100644 --- a/test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/CastleInterceptionTestBase.cs +++ b/test/Volo.Abp.Tests/Volo/Abp/DynamicProxy/AbpInterceptionTestBase.cs @@ -5,12 +5,30 @@ using Volo.Abp.Modularity; using Volo.Abp.TestBase; using Xunit; -namespace Volo.Abp.Castle.DynamicProxy +namespace Volo.Abp.DynamicProxy { - //TODO: There is no Castle Dependency here.. We can move this base class directly to Volo.Abp.Tests - public abstract class CastleInterceptionTestBase : AbpIntegratedTest + public abstract class AbpInterceptionTestBase : AbpIntegratedTest where TStartupModule : IAbpModule { + protected override void BeforeAddApplication(IServiceCollection services) + { + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + services.AddTransient(); + + services.OnServiceRegistred(registration => + { + //TODO: Create an attribute to add interceptors! + if (typeof(SimpleInterceptionTargetClass) == registration.ImplementationType) + { + registration.Interceptors.Add(); + registration.Interceptors.Add(); + registration.Interceptors.Add(); + } + }); + } + [Fact] public async Task Should_Intercept_Async_Method_Without_Return_Value() { diff --git a/test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/SimpleAsyncInterceptor.cs b/test/Volo.Abp.Tests/Volo/Abp/DynamicProxy/SimpleAsyncInterceptor.cs similarity index 86% rename from test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/SimpleAsyncInterceptor.cs rename to test/Volo.Abp.Tests/Volo/Abp/DynamicProxy/SimpleAsyncInterceptor.cs index c1ee13b496..8153b6fd65 100644 --- a/test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/SimpleAsyncInterceptor.cs +++ b/test/Volo.Abp.Tests/Volo/Abp/DynamicProxy/SimpleAsyncInterceptor.cs @@ -1,11 +1,10 @@ using System.Threading.Tasks; -using Volo.Abp.DynamicProxy; using Volo.Abp.TestBase.Logging; using Volo.DependencyInjection; -namespace Volo.Abp.Castle.DynamicProxy +namespace Volo.Abp.DynamicProxy { - public class SimpleAsyncInterceptor : AbpInterceptor, ITransientDependency + public class SimpleAsyncInterceptor : AbpInterceptor { public override void Intercept(IAbpMethodInvocation invocation) { diff --git a/test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/SimpleAsyncInterceptor2.cs b/test/Volo.Abp.Tests/Volo/Abp/DynamicProxy/SimpleAsyncInterceptor2.cs similarity index 64% rename from test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/SimpleAsyncInterceptor2.cs rename to test/Volo.Abp.Tests/Volo/Abp/DynamicProxy/SimpleAsyncInterceptor2.cs index 9a1ce837dd..4048c947a4 100644 --- a/test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/SimpleAsyncInterceptor2.cs +++ b/test/Volo.Abp.Tests/Volo/Abp/DynamicProxy/SimpleAsyncInterceptor2.cs @@ -1,4 +1,4 @@ -namespace Volo.Abp.Castle.DynamicProxy +namespace Volo.Abp.DynamicProxy { public class SimpleAsyncInterceptor2 : SimpleAsyncInterceptor { diff --git a/test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/SimpleInterceptionTargetClass.cs b/test/Volo.Abp.Tests/Volo/Abp/DynamicProxy/SimpleInterceptionTargetClass.cs similarity index 85% rename from test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/SimpleInterceptionTargetClass.cs rename to test/Volo.Abp.Tests/Volo/Abp/DynamicProxy/SimpleInterceptionTargetClass.cs index 74d0ac6d95..d1f23ea34c 100644 --- a/test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/SimpleInterceptionTargetClass.cs +++ b/test/Volo.Abp.Tests/Volo/Abp/DynamicProxy/SimpleInterceptionTargetClass.cs @@ -1,11 +1,10 @@ using System.Collections.Generic; using System.Threading.Tasks; using Volo.Abp.TestBase.Logging; -using Volo.DependencyInjection; -namespace Volo.Abp.Castle.DynamicProxy +namespace Volo.Abp.DynamicProxy { - public class SimpleInterceptionTargetClass : ITransientDependency, ICanLogOnObject + public class SimpleInterceptionTargetClass : ICanLogOnObject { public List Logs { get; } = new List(); diff --git a/test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/SimpleSyncInterceptor.cs b/test/Volo.Abp.Tests/Volo/Abp/DynamicProxy/SimpleSyncInterceptor.cs similarity index 72% rename from test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/SimpleSyncInterceptor.cs rename to test/Volo.Abp.Tests/Volo/Abp/DynamicProxy/SimpleSyncInterceptor.cs index 0c9a1abe3c..19fb5270e2 100644 --- a/test/Volo.Abp.Castle.Core.Tests/Volo/Abp/Castle/DynamicProxy/SimpleSyncInterceptor.cs +++ b/test/Volo.Abp.Tests/Volo/Abp/DynamicProxy/SimpleSyncInterceptor.cs @@ -1,10 +1,9 @@ -using Volo.Abp.DynamicProxy; using Volo.Abp.TestBase.Logging; using Volo.DependencyInjection; -namespace Volo.Abp.Castle.DynamicProxy +namespace Volo.Abp.DynamicProxy { - public class SimpleSyncInterceptor : AbpInterceptor, ITransientDependency + public class SimpleSyncInterceptor : AbpInterceptor { public override void Intercept(IAbpMethodInvocation invocation) {