예제 #1
0
        static AppFixture()
        {
            _configuration = new ConfigurationBuilder()
                             .SetBasePath(Directory.GetCurrentDirectory())
                             .AddJsonFile("appsettings.json")
                             .AddEnvironmentVariables()
                             .Build();

            var startup  = new Startup(_configuration, new HostEnvironment());
            var services = new ServiceCollection();

            startup.ConfigureServices(services);
            var builder = new AutofacServiceProviderFactory().CreateBuilder(services);

            startup.ConfigureContainer(builder);
            builder.RegisterType <NullDispatcher>().As <IDomainEventDispatcher>(); // replace with null dispatcher

            var container = builder.Build();

            _scopeFactory = container.Resolve <IServiceScopeFactory>();
            _checkpoint   = new Checkpoint
            {
                DbAdapter      = DbAdapter.Postgres,
                TablesToIgnore = new[]
                {
                    "unit_of_measure_lib",
                    "migration_history"
                }
            };

            ConnectionString = _configuration.GetConnectionString("Postgres");
            Debug.Assert(ConnectionString.Contains("_test"));
        }
예제 #2
0
        private void InitApi()
        {
            ContainerBuilder builder = new AutofacServiceProviderFactory().CreateBuilder(new ServiceCollection().AddHttpClient());

            builder.RegisterType <BlizzardApiReader>().As <IBlizzardApiReader>();
            builder.RegisterType <ApiWebClient>().As <IWebClient>();
            builder.Register(c => Options.Create(Configuration.GetSection("BlizzardApi").Get <BlizzardApiConfiguration>())).As <IOptions <BlizzardApiConfiguration> >();

            Api = builder.Build().Resolve <IBlizzardApiReader>();
        }