using Abp.AspNetCore;
using Abp.AspNetCore.TestBase;
using Abp.Modules;
using Abp.Reflection.Extensions;
using MineTec.ProManager.EntityFrameworkCore;
using MineTec.ProManager.Admin.ViewResources;
using Microsoft.AspNetCore.Mvc.ApplicationParts;

namespace MineTec.ProManager.Admin.Tests
{
    [DependsOn(
        typeof(ProManagerAdminModule),
        typeof(AbpAspNetCoreTestBaseModule)
    )]
    public class ProManagerWebTestModule : AbpModule
    {
        public ProManagerWebTestModule(ProManagerEntityFrameworkModule abpProjectNameEntityFrameworkModule)
        {
            abpProjectNameEntityFrameworkModule.SkipDbContextRegistration = true;
        } 
        
        public override void PreInitialize()
        {
            Configuration.UnitOfWork.IsTransactional = false; //EF Core InMemory DB does not support transactions.
        }

        public override void Initialize()
        {
            IocManager.RegisterAssemblyByConvention(typeof(ProManagerWebTestModule).GetAssembly());
        }
        
        public override void PostInitialize()
        {
            IocManager.Resolve<ApplicationPartManager>()
                .AddApplicationPartsIfNotAddedBefore(typeof(ProManagerAdminModule).Assembly);
        }
    }
}