using System;
using Microsoft.Extensions.DependencyInjection;
using Volo.Abp.Modularity;
using Volo.Abp.TestApp.MemoryDb;
using Volo.Abp.Data;
using Volo.Abp.Autofac;
using Volo.Abp.TestApp;
using Volo.Abp.TestApp.Domain;

namespace Volo.Abp.MemoryDb
{
    [DependsOn(
        typeof(TestAppModule), 
        typeof(AbpMemoryDbModule), 
        typeof(AbpAutofacModule))]
    public class AbpMemoryDbTestModule : AbpModule
    {
        public override void ConfigureServices(IServiceCollection services)
        {
            var connStr = Guid.NewGuid().ToString();

            services.Configure<DbConnectionOptions>(options =>
            {
                options.ConnectionStrings.Default = connStr;
            });

            services.AddMemoryDbContext<TestAppMemoryDbContext>(options =>
            {
                options.AddDefaultRepositories();
                options.AddRepository<City, CityRepository>();
            });

            services.AddAssemblyOf<AbpMemoryDbTestModule>();
        }
    }
}
