diff --git a/Volo.Abp.sln b/Volo.Abp.sln index f94fa81e50..2aebb01576 100644 --- a/Volo.Abp.sln +++ b/Volo.Abp.sln @@ -252,6 +252,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Settings.EntityFra EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Volo.Abp.Settings.Domain", "src\Volo.Abp.Settings.Domain\Volo.Abp.Settings.Domain.csproj", "{837BC537-3AEC-4F6D-9D64-9704F64D0E1E}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Volo.Abp.Settings.Tests", "test\Volo.Abp.Settings.Tests\Volo.Abp.Settings.Tests.csproj", "{61422EC8-8FFB-48EA-B4B5-527E29077930}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -658,6 +660,10 @@ Global {837BC537-3AEC-4F6D-9D64-9704F64D0E1E}.Debug|Any CPU.Build.0 = Debug|Any CPU {837BC537-3AEC-4F6D-9D64-9704F64D0E1E}.Release|Any CPU.ActiveCfg = Release|Any CPU {837BC537-3AEC-4F6D-9D64-9704F64D0E1E}.Release|Any CPU.Build.0 = Release|Any CPU + {61422EC8-8FFB-48EA-B4B5-527E29077930}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {61422EC8-8FFB-48EA-B4B5-527E29077930}.Debug|Any CPU.Build.0 = Debug|Any CPU + {61422EC8-8FFB-48EA-B4B5-527E29077930}.Release|Any CPU.ActiveCfg = Release|Any CPU + {61422EC8-8FFB-48EA-B4B5-527E29077930}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -780,6 +786,7 @@ Global {CB6FD800-B6C5-4C2A-8920-B8A29C74AEF6} = {4C753F64-0C93-4D65-96C2-A40893AFC1E8} {1DCD9600-215A-4A94-AEFD-577568D62633} = {4C753F64-0C93-4D65-96C2-A40893AFC1E8} {837BC537-3AEC-4F6D-9D64-9704F64D0E1E} = {4C753F64-0C93-4D65-96C2-A40893AFC1E8} + {61422EC8-8FFB-48EA-B4B5-527E29077930} = {37087D1B-3693-4E96-983D-A69F210BDE53} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {BB97ECF4-9A84-433F-A80B-2A3285BDD1D5} diff --git a/src/Volo.Abp.Settings.EntityFrameworkCore/Volo/Abp/Settings/EntityFrameworkCore/AbpSettingsEntityFrameworkCoreModule.cs b/src/Volo.Abp.Settings.EntityFrameworkCore/Volo/Abp/Settings/EntityFrameworkCore/AbpSettingsEntityFrameworkCoreModule.cs index 8b906f1579..013c32d16f 100644 --- a/src/Volo.Abp.Settings.EntityFrameworkCore/Volo/Abp/Settings/EntityFrameworkCore/AbpSettingsEntityFrameworkCoreModule.cs +++ b/src/Volo.Abp.Settings.EntityFrameworkCore/Volo/Abp/Settings/EntityFrameworkCore/AbpSettingsEntityFrameworkCoreModule.cs @@ -1,10 +1,11 @@ using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.EntityFrameworkCore; using Volo.Abp.Modularity; namespace Volo.Abp.Settings.EntityFrameworkCore { [DependsOn(typeof(AbpSettingsDomainModule))] - [DependsOn(typeof(AbpSettingsEntityFrameworkCoreModule))] + [DependsOn(typeof(AbpEntityFrameworkCoreModule))] public class AbpSettingsEntityFrameworkCoreModule : AbpModule { public override void ConfigureServices(IServiceCollection services) diff --git a/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingManager.cs b/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingManager.cs index da9a9c7b83..2f1d1ffcaf 100644 --- a/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingManager.cs +++ b/src/Volo.Abp.Settings/Volo/Abp/Settings/SettingManager.cs @@ -1,9 +1,10 @@ using System.Collections.Generic; using System.Threading.Tasks; +using Volo.Abp.DependencyInjection; namespace Volo.Abp.Settings { - public class SettingManager : ISettingManager + public class SettingManager : ISettingManager, ITransientDependency { public Task GetOrNullAsync(string name) { diff --git a/test/Volo.Abp.MultiTenancy.Tests/Volo.Abp.MultiTenancy.Tests.csproj b/test/Volo.Abp.MultiTenancy.Tests/Volo.Abp.MultiTenancy.Tests.csproj index a76a44b67d..8967428388 100644 --- a/test/Volo.Abp.MultiTenancy.Tests/Volo.Abp.MultiTenancy.Tests.csproj +++ b/test/Volo.Abp.MultiTenancy.Tests/Volo.Abp.MultiTenancy.Tests.csproj @@ -19,9 +19,5 @@ - - - - diff --git a/test/Volo.Abp.Settings.Tests/Volo.Abp.Settings.Tests.csproj b/test/Volo.Abp.Settings.Tests/Volo.Abp.Settings.Tests.csproj new file mode 100644 index 0000000000..df86c0a460 --- /dev/null +++ b/test/Volo.Abp.Settings.Tests/Volo.Abp.Settings.Tests.csproj @@ -0,0 +1,25 @@ + + + + netcoreapp2.0 + Volo.Abp.MultiTenancy.Tests + Volo.Abp.MultiTenancy.Tests + true + false + false + false + + + + + + + + + + + + + + + diff --git a/test/Volo.Abp.Settings.Tests/Volo/Abp/Settings/AbpIdentityApplicationTestBase.cs b/test/Volo.Abp.Settings.Tests/Volo/Abp/Settings/AbpIdentityApplicationTestBase.cs new file mode 100644 index 0000000000..4f2f07fcfb --- /dev/null +++ b/test/Volo.Abp.Settings.Tests/Volo/Abp/Settings/AbpIdentityApplicationTestBase.cs @@ -0,0 +1,12 @@ +using Volo.Abp.TestBase; + +namespace Volo.Abp.Settings +{ + public class AbpSettingsTestBase : AbpIntegratedTest + { + protected override void SetAbpApplicationCreationOptions(AbpApplicationCreationOptions options) + { + options.UseAutofac(); + } + } +} diff --git a/test/Volo.Abp.Settings.Tests/Volo/Abp/Settings/AbpIdentityApplicationTestModule.cs b/test/Volo.Abp.Settings.Tests/Volo/Abp/Settings/AbpIdentityApplicationTestModule.cs new file mode 100644 index 0000000000..7015bda9cc --- /dev/null +++ b/test/Volo.Abp.Settings.Tests/Volo/Abp/Settings/AbpIdentityApplicationTestModule.cs @@ -0,0 +1,52 @@ +using System; +using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; +using Volo.Abp.Autofac; +using Volo.Abp.EntityFrameworkCore; +using Volo.Abp.Modularity; +using Volo.Abp.Settings.EntityFrameworkCore; +using Volo.Abp.Uow; + +namespace Volo.Abp.Settings +{ + [DependsOn(typeof(AbpSettingsEntityFrameworkCoreModule), typeof(AbpAutofacModule))] + public class AbpSettingsTestModule : AbpModule + { + public override void ConfigureServices(IServiceCollection services) + { + services.AddAssemblyOf(); + + services.AddEntityFrameworkInMemoryDatabase(); + + var databaseName = Guid.NewGuid().ToString(); + + services.Configure(options => + { + options.Configure(context => + { + context.DbContextOptions.UseInMemoryDatabase(databaseName); + }); + }); + + services.Configure(options => + { + options.TransactionBehavior = UnitOfWorkTransactionBehavior.Disabled; //EF in-memory database does not support transactions + }); + } + + public override void OnApplicationInitialization(ApplicationInitializationContext context) + { + SeedTestData(context); + } + + private static void SeedTestData(ApplicationInitializationContext context) + { + using (var scope = context.ServiceProvider.CreateScope()) + { + scope.ServiceProvider + .GetRequiredService() + .Build(); + } + } + } +} diff --git a/test/Volo.Abp.Settings.Tests/Volo/Abp/Settings/AbpIdentityTestDataBuilder.cs b/test/Volo.Abp.Settings.Tests/Volo/Abp/Settings/AbpIdentityTestDataBuilder.cs new file mode 100644 index 0000000000..9201cfa777 --- /dev/null +++ b/test/Volo.Abp.Settings.Tests/Volo/Abp/Settings/AbpIdentityTestDataBuilder.cs @@ -0,0 +1,23 @@ +using Volo.Abp.DependencyInjection; +using Volo.Abp.Guids; + +namespace Volo.Abp.Settings +{ + public class AbpIdentityTestDataBuilder : ITransientDependency + { + private readonly ISettingRepository _settingRepository; + private readonly IGuidGenerator _guidGenerator; + + public AbpIdentityTestDataBuilder(ISettingRepository settingRepository, IGuidGenerator guidGenerator) + { + _settingRepository = settingRepository; + _guidGenerator = guidGenerator; + } + + public void Build() + { + _settingRepository.InsertAsync(new Setting(_guidGenerator.Create(), "MySetting1", "42")); + _settingRepository.InsertAsync(new Setting(_guidGenerator.Create(), "MySetting2", "55")); + } + } +} \ No newline at end of file diff --git a/test/Volo.Abp.Settings.Tests/Volo/Abp/Settings/SettingManager_Tests.cs b/test/Volo.Abp.Settings.Tests/Volo/Abp/Settings/SettingManager_Tests.cs new file mode 100644 index 0000000000..0c34713b69 --- /dev/null +++ b/test/Volo.Abp.Settings.Tests/Volo/Abp/Settings/SettingManager_Tests.cs @@ -0,0 +1,20 @@ +using Xunit; + +namespace Volo.Abp.Settings +{ + public class SettingManager_Tests : AbpSettingsTestBase + { + private readonly ISettingManager _settingManager; + + public SettingManager_Tests() + { + _settingManager = GetRequiredService(); + } + + [Fact] + public void Test1() + { + + } + } +}