You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
abp/framework/test/Volo.Abp.MongoDB.Tests/Volo/Abp/MongoDB/AbpMongoDbTestModule.cs

39 lines
1.2 KiB

using System;
using Microsoft.Extensions.DependencyInjection;
using Mongo2Go;
using Volo.Abp.Data;
using Volo.Abp.Modularity;
using Volo.Abp.TestApp;
using Volo.Abp.TestApp.Domain;
using Volo.Abp.TestApp.MongoDB;
namespace Volo.Abp.MongoDB
{
[DependsOn(
typeof(AbpMongoDbModule),
typeof(TestAppModule)
)]
public class AbpMongoDbTestModule : AbpModule
{
private static readonly MongoDbRunner MongoDbRunner = MongoDbRunner.Start();
public override void ConfigureServices(ServiceConfigurationContext context)
{
var connectionString = MongoDbRunner.ConnectionString.EnsureEndsWith('/') +
6 years ago
"Db_" +
Guid.NewGuid().ToString("N");
Configure<AbpDbConnectionOptions>(options =>
{
options.ConnectionStrings.Default = connectionString;
});
context.Services.AddMongoDbContext<TestAppMongoDbContext>(options =>
{
options.AddDefaultRepositories<ITestAppMongoDbContext>();
options.AddRepository<City, CityRepository>();
});
}
}
}