public UnitTest1() { //ÅäÖÃÊÖ½Å¼Ü KenCoreGlobalConfiguration.Configuration(settings => { settings.UseRedisDataBase("192.168.10.222:6379"); }); Bootstrapper.Initialize(); }
// This method gets called by the runtime. Use this method to add services to the container. public IServiceProvider ConfigureServices(IServiceCollection services) { services.Configure <CookiePolicyOptions>(options => { // This lambda determines whether user consent for non-essential cookies is needed for a given request. options.CheckConsentNeeded = context => true; options.MinimumSameSitePolicy = SameSiteMode.None; }); services.AddSingleton <IHttpContextAccessor, HttpContextAccessor>(); services.Configure <Data>(c => { c.Provider = (DataProvider)Enum.Parse( typeof(DataProvider), Configuration.GetSection("Data")["Provider"]); }); services.Configure <ConnectionStrings>(Configuration.GetSection("ConnectionStrings")); services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1); var logCfg = new FileInfo(AppDomain.CurrentDomain.BaseDirectory + "log4net.config"); XmlConfigurator.ConfigureAndWatch(LogManager.CreateRepository("NETCoreRepository"), logCfg); Bootstrapper bootstrappe = Bootstrapper.Create <ServiceModule>(); bootstrappe.IocManager.ContainerBuilder.Populate(services); var mongo = _appConfiguration.GetConnectionString("KenData"); var re = _appConfiguration.GetConnectionString("Redis"); KenCoreGlobalConfiguration.Configuration(settings => { settings .UseRedisDataBase(_appConfiguration.GetConnectionString("Redis")) .MasterDataBases("KenData", _appConfiguration.GetConnectionString("KenData")); }); bootstrappe.Initialize(); return(new AutofacServiceProvider(bootstrappe.IocManager.Container)); }