// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.Configure <DirectoryDbSettings>(Configuration.GetSection(nameof(DirectoryDbSettings))); services.AddSingleton <IDirectoryDbSettings>(sp => sp.GetRequiredService <IOptions <DirectoryDbSettings> >().Value); services.AddMvc(); services.AddAuthentication() .AddOpenIdConnectServer(options => { options.Provider = new AuthorizationProvider(); options.AuthorizationEndpointPath = "/connect/authorize"; options.TokenEndpointPath = "/connect/token"; options.AllowInsecureHttp = true; }); /* * services.AddDistributedRedisCache(option => * { * option.Configuration = Configuration["ExternalConnections:RedisConnection"]; * option.InstanceName = "master"; * });*/ ServiceDependencyResolver.Resolve(services); }
public DatabaseSetUpHelper() { // Builds webhost and gets service providers from web host var webHost = WebHost.CreateDefaultBuilder() .UseStartup <Startup>() .Build(); _serviceProvider = new ServiceDependencyResolver(webHost); // Resets database to inital state so all tests are isolated and repeatable _context = new FlatManagementContext(); _context.Database.EnsureDeleted(); _context.Database.EnsureCreated(); var testDataGenerator = new DevelopmentDatabaseSetup(_context); testDataGenerator.SetupDevelopmentDataSet(); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 public void ConfigureServices(IServiceCollection services) { services.Configure <DirectoryDbSettings>(Configuration.GetSection(nameof(DirectoryDbSettings))); services.AddSingleton <IDirectoryDbSettings>(sp => sp.GetRequiredService <IOptions <DirectoryDbSettings> >().Value); services.AddMvc(); services.AddAuthentication(CookieAuthenticationDefaults.AuthenticationScheme) .AddCookie(options => { options.LoginPath = "/account/login"; }); /*services.AddDistributedRedisCache(option => * { * option.Configuration = Configuration["ExternalConnections:RedisConnection"]; * option.InstanceName = "master"; * });*/ ServiceDependencyResolver.Resolve(services); }