Resolve #1632 MongoDB test problems & optimization.

pull/1634/head
maliming 6 years ago
parent 0614a68710
commit ff66516a93

@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using Microsoft.Extensions.DependencyInjection;
using Mongo2Go;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
@ -14,15 +15,17 @@ namespace Volo.Abp.MongoDB
)]
public class AbpMongoDbTestModule : AbpModule
{
private MongoDbRunner _mongoDbRunner;
private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start();
public override void ConfigureServices(ServiceConfigurationContext context)
{
_mongoDbRunner = MongoDbRunner.Start();
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
"Db_" +
Guid.NewGuid().ToString("N");
Configure<DbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = _mongoDbRunner.ConnectionString;
options.ConnectionStrings.Default = connectionString;
});
context.Services.AddMongoDbContext<TestAppMongoDbContext>(options =>
@ -31,10 +34,5 @@ namespace Volo.Abp.MongoDB
options.AddRepository<City, CityRepository>();
});
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
_mongoDbRunner.Dispose();
}
}
}

@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using Microsoft.Extensions.DependencyInjection;
using Mongo2Go;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
@ -11,21 +12,18 @@ namespace Volo.Abp.AuditLogging.MongoDB
)]
public class AbpAuditLoggingMongoDbTestModule : AbpModule
{
private MongoDbRunner _mongoDbRunner;
private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start();
public override void ConfigureServices(ServiceConfigurationContext context)
{
_mongoDbRunner = MongoDbRunner.Start();
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
"Db_" +
Guid.NewGuid().ToString("N");
Configure<DbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = _mongoDbRunner.ConnectionString;
options.ConnectionStrings.Default = connectionString;
});
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
_mongoDbRunner.Dispose();
}
}
}

@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using Microsoft.Extensions.DependencyInjection;
using Mongo2Go;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
@ -11,21 +12,18 @@ namespace Volo.Abp.BackgroundJobs.MongoDB
)]
public class BackgroundJobsMongoDbTestModule : AbpModule
{
private MongoDbRunner _mongoDbRunner;
private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start();
public override void ConfigureServices(ServiceConfigurationContext context)
{
_mongoDbRunner = MongoDbRunner.Start();
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
"Db_" +
Guid.NewGuid().ToString("N");
Configure<DbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = _mongoDbRunner.ConnectionString;
options.ConnectionStrings.Default = connectionString;
});
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
_mongoDbRunner.Dispose();
}
}
}

@ -1,4 +1,5 @@
using Mongo2Go;
using System;
using Mongo2Go;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
@ -11,21 +12,18 @@ namespace Volo.Blogging.MongoDB
)]
public class BloggingMongoDbTestModule : AbpModule
{
private MongoDbRunner _mongoDbRunner;
private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start();
public override void ConfigureServices(ServiceConfigurationContext context)
{
_mongoDbRunner = MongoDbRunner.Start();
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
"Db_" +
Guid.NewGuid().ToString("N");
Configure<DbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = _mongoDbRunner.ConnectionString;
options.ConnectionStrings.Default = connectionString;
});
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
_mongoDbRunner.Dispose();
}
}
}

@ -1,4 +1,5 @@
using Mongo2Go;
using System;
using Mongo2Go;
using Volo.Abp;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
@ -11,21 +12,18 @@ namespace Volo.Docs.MongoDB
)]
public class DocsMongoDBTestModule : AbpModule
{
private MongoDbRunner _mongoDbRunner;
private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start();
public override void ConfigureServices(ServiceConfigurationContext context)
{
_mongoDbRunner = MongoDbRunner.Start();
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
"Db_" +
Guid.NewGuid().ToString("N");
Configure<DbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = _mongoDbRunner.ConnectionString;
options.ConnectionStrings.Default = connectionString;
});
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
_mongoDbRunner.Dispose();
}
}
}

@ -1,4 +1,5 @@
using Mongo2Go;
using System;
using Mongo2Go;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
@ -10,21 +11,18 @@ namespace Volo.Abp.FeatureManagement.MongoDB
)]
public class AbpFeatureManagementMongoDbTestModule : AbpModule
{
private MongoDbRunner _mongoDbRunner;
private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start();
public override void ConfigureServices(ServiceConfigurationContext context)
{
_mongoDbRunner = MongoDbRunner.Start();
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
"Db_" +
Guid.NewGuid().ToString("N");
Configure<DbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = _mongoDbRunner.ConnectionString;
options.ConnectionStrings.Default = connectionString;
});
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
_mongoDbRunner.Dispose();
}
}
}

@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using Microsoft.Extensions.DependencyInjection;
using Mongo2Go;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
@ -13,21 +14,18 @@ namespace Volo.Abp.Identity.MongoDB
)]
public class AbpIdentityMongoDbTestModule : AbpModule
{
private MongoDbRunner _mongoDbRunner;
private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start();
public override void ConfigureServices(ServiceConfigurationContext context)
{
_mongoDbRunner = MongoDbRunner.Start();
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
"Db_" +
Guid.NewGuid().ToString("N");
Configure<DbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = _mongoDbRunner.ConnectionString;
options.ConnectionStrings.Default = connectionString;
});
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
_mongoDbRunner.Dispose();
}
}
}

@ -1,4 +1,5 @@
using Mongo2Go;
using System;
using Mongo2Go;
using Volo.Abp.Data;
using Volo.Abp.Identity.MongoDB;
using Volo.Abp.IdentityServer.MongoDB;
@ -14,21 +15,18 @@ namespace Volo.Abp.IdentityServer
)]
public class AbpIdentityServerMongoDbTestModule : AbpModule
{
private MongoDbRunner _mongoDbRunner;
private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start();
public override void ConfigureServices(ServiceConfigurationContext context)
{
_mongoDbRunner = MongoDbRunner.Start();
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
"Db_" +
Guid.NewGuid().ToString("N");
Configure<DbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = _mongoDbRunner.ConnectionString;
options.ConnectionStrings.Default = connectionString;
});
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
_mongoDbRunner.Dispose();
}
}
}

@ -1,4 +1,5 @@
using Mongo2Go;
using System;
using Mongo2Go;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
@ -9,21 +10,18 @@ namespace Volo.Abp.PermissionManagement.MongoDB
typeof(AbpPermissionManagementTestBaseModule))]
public class AbpPermissionManagementMongoDbTestModule : AbpModule
{
private MongoDbRunner _mongoDbRunner;
private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start();
public override void ConfigureServices(ServiceConfigurationContext context)
{
_mongoDbRunner = MongoDbRunner.Start();
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
"Db_" +
Guid.NewGuid().ToString("N");
Configure<DbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = _mongoDbRunner.ConnectionString;
options.ConnectionStrings.Default = connectionString;
});
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
_mongoDbRunner.Dispose();
}
}
}

@ -1,4 +1,5 @@
using Mongo2Go;
using System;
using Mongo2Go;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
@ -10,21 +11,18 @@ namespace Volo.Abp.SettingManagement.MongoDB
)]
public class AbpSettingManagementMongoDbTestModule : AbpModule
{
private MongoDbRunner _mongoDbRunner;
private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start();
public override void ConfigureServices(ServiceConfigurationContext context)
{
_mongoDbRunner = MongoDbRunner.Start();
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
"Db_" +
Guid.NewGuid().ToString("N");
Configure<DbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = _mongoDbRunner.ConnectionString;
options.ConnectionStrings.Default = connectionString;
});
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
_mongoDbRunner.Dispose();
}
}
}

@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using Microsoft.Extensions.DependencyInjection;
using Mongo2Go;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
@ -11,21 +12,18 @@ namespace Volo.Abp.TenantManagement.MongoDB
)]
public class AbpTenantManagementMongoDbTestModule : AbpModule
{
private MongoDbRunner _mongoDbRunner;
private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start();
public override void ConfigureServices(ServiceConfigurationContext context)
{
_mongoDbRunner = MongoDbRunner.Start();
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
"Db_" +
Guid.NewGuid().ToString("N");
Configure<DbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = _mongoDbRunner.ConnectionString;
options.ConnectionStrings.Default = connectionString;
});
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
_mongoDbRunner.Dispose();
}
}
}

@ -1,4 +1,5 @@
using Microsoft.Extensions.DependencyInjection;
using System;
using Microsoft.Extensions.DependencyInjection;
using Mongo2Go;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
@ -11,23 +12,20 @@ namespace Volo.Abp.Users.MongoDB
)]
public class AbpUsersMongoDbTestModule : AbpModule
{
private MongoDbRunner _mongoDbRunner;
private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start();
public override void ConfigureServices(IServiceCollection services)
{
_mongoDbRunner = MongoDbRunner.Start();
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
"Db_" +
Guid.NewGuid().ToString("N");
services.Configure<DbConnectionOptions>(options =>
Configure<DbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = _mongoDbRunner.ConnectionString;
options.ConnectionStrings.Default = connectionString;
});
services.AddAssemblyOf<AbpUsersMongoDbTestModule>();
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
_mongoDbRunner.Dispose();
}
}
}

@ -16,8 +16,8 @@ namespace Acme.BookStore.MongoDB
public override void ConfigureServices(ServiceConfigurationContext context)
{
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
"BookStore_" +
Guid.NewGuid().ToString("N");
"Db_" +
Guid.NewGuid().ToString("N");
Configure<DbConnectionOptions>(options =>
{

@ -16,8 +16,8 @@ namespace MyCompanyName.MyProjectName.MongoDB
public override void ConfigureServices(ServiceConfigurationContext context)
{
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
"MyProjectName_" +
Guid.NewGuid().ToString("N");
"Db_" +
Guid.NewGuid().ToString("N");
Configure<DbConnectionOptions>(options =>
{

@ -12,21 +12,18 @@ namespace MyCompanyName.MyProjectName.MongoDB
)]
public class MyProjectNameMongoDbTestModule : AbpModule
{
private MongoDbRunner _mongoDbRunner;
private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start();
public override void ConfigureServices(ServiceConfigurationContext context)
{
_mongoDbRunner = MongoDbRunner.Start();
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
"Db_" +
Guid.NewGuid().ToString("N");
Configure<DbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = _mongoDbRunner.ConnectionString.EnsureEndsWith('/') + "MyProjectName";
options.ConnectionStrings.Default = connectionString;
});
}
public override void OnApplicationShutdown(ApplicationShutdownContext context)
{
_mongoDbRunner.Dispose();
}
}
}
Loading…
Cancel
Save