public WarmupInMemory()
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("app.json", optional: true, reloadOnChange: true);

            //Mock IHttpContextAccessor
            var mockHttpContextAccessor = new Mock <IHttpContextAccessor>();
            var serviceCollection       = new ServiceCollection();

            serviceCollection.AddScoped <IConfiguration>(s => builder.Build());

            void DatabaseOptions(DbContextOptionsBuilder opt) => opt.UseInMemoryDatabase("JpTests").EnableSensitiveDataLogging();

            serviceCollection
            .ConfigureUserIdentity <AspNetUserTest>()
            .WithSqlServer(DatabaseOptions)

            .ConfigureIdentityServer()
            .WithSqlServer(DatabaseOptions);

            serviceCollection.AddEventStoreContext(DatabaseOptions);

            var configurationExpression = new MapperConfigurationExpression();

            SsoMapperConfig.RegisterMappings().ForEach(p => configurationExpression.AddProfile(p));
            var automapperConfig = new MapperConfiguration(configurationExpression);

            serviceCollection.TryAddSingleton(automapperConfig.CreateMapper());
            serviceCollection.AddMediatR(typeof(WarmupInMemory));
            serviceCollection.TryAddSingleton <IHttpContextAccessor>(mockHttpContextAccessor.Object);

            Services = serviceCollection.BuildServiceProvider();
        }
        public static void ConfigureDefaultSettings(this IServiceCollection services)
        {
            var configurationExpression = new MapperConfigurationExpression();

            AdminUiMapperConfiguration.RegisterMappings().ForEach(p => configurationExpression.AddProfile(p));
            SsoMapperConfig.RegisterMappings().ForEach(p => configurationExpression.AddProfile(p));
            configurationExpression.AddProfile(new CustomMappingProfile());
            var automapperConfig = new MapperConfiguration(configurationExpression);

            services.TryAddSingleton(automapperConfig.CreateMapper());
            // Adding MediatR for Domain Events and Notifications
            services.AddMediatR(typeof(Startup));
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();

            var database   = Configuration.GetValue <DatabaseType>("ApplicationSettings:DatabaseType");
            var connString = Configuration.GetConnectionString("SSOConnection");

            services
            .ConfigureUserIdentity <AspNetUser>().AddDatabase(database, connString)
            .ConfigureIdentityServer().AddOAuth2Database(database, connString);

            var configurationExpression = new MapperConfigurationExpression();

            SsoMapperConfig.RegisterMappings().ForEach(p => configurationExpression.AddProfile(p));
            var automapperConfig = new MapperConfiguration(configurationExpression);

            services.TryAddSingleton(automapperConfig.CreateMapper());
            // Adding MediatR for Domain Events and Notifications
            services.AddMediatR(typeof(Startup));
        }
        public static void ConfigureSso(this IServiceCollection services, IConfiguration configuration)
        {
            var database   = configuration.GetValue <DatabaseType>("ApplicationSettings:DatabaseType");
            var connString = configuration.GetConnectionString("SSOConnection");

            services
            .ConfigureUserIdentity <AspNetUser>().AddDatabase(database, connString)
            .AddCustomClaimsFactory <ApplicationClaimsIdentityFactory>()
            .ConfigureIdentityServer()

            .AddSigninCredentialFromConfig(configuration.GetSection("CertificateOptions"))
            .AddOAuth2Database(database, connString);

            var configurationExpression = new MapperConfigurationExpression();

            SsoMapperConfig.RegisterMappings().ForEach(p => configurationExpression.AddProfile(p));
            configurationExpression.AddProfile(new CustomMappingProfile());
            var automapperConfig = new MapperConfiguration(configurationExpression);

            services.TryAddSingleton(automapperConfig.CreateMapper());
            // Adding MediatR for Domain Events and Notifications
            services.AddMediatR(typeof(Startup));
        }