protected IntegrationTestBase()
        {
            _server = new Microsoft.AspNetCore.TestHost.TestServer(new WebHostBuilder()
                                                                   .UseStartup <IdentityFramework.Iam.TestServer.Startup>()
                                                                   .ConfigureAppConfiguration((hostingContext, config) =>
            {
                config.AddJsonFile("appsettings.json", optional: false, reloadOnChange: true);
                config.AddEnvironmentVariables();
                config.AddInMemoryCollection(new Dictionary <string, string>()
                {
                    { "UseMultitenancy", "false" },
                    { "TestMode", "true" }
                });
            })
                                                                   .ConfigureTestServices(services =>
            {
                services.AddIdentity <User, Role>()
                .AddEntityFrameworkStores <IamDbContext <User, Role, long> >()
                .AddDefaultTokenProviders();

                services.AddAuthentication(options =>
                {
                    options.DefaultAuthenticateScheme = "Bearer";
                    options.DefaultChallengeScheme    = "Bearer";
                }).AddJwtBearer(configureOptions =>
                {
                    configureOptions.ClaimsIssuer = Startup.TokenValidationParameters.ValidIssuer;
                    configureOptions.TokenValidationParameters = Startup.TokenValidationParameters;
                    configureOptions.SaveToken = true;
                });

                services.AddAuthorization();

                services.AddMvc();

                services.AddIamEntityFramework <User, Role, long>(options =>
                                                                  options.UseSqlServer(ConfigurationHelper.GetConnectionString()));
            }));

            IdentityFramework.Iam.TestServer.Program.SeedData(_server.Host.Services, typeof(IamDbContext <User, Role, long>), ConfigurationHelper.GetConnectionString());
        }