예제 #1
0
        public TestContext CreateBuilderContextFactoryByDiConfigGlobalDefault()
        {
            IServiceCollection service = new ServiceCollection();

            service.AddDataContextFactory <TestContextFactory, TestContext>(DataContextConfiguration.Global, config =>
            {
                config.SetCommandOutput(commandOutput);
            }, ServiceLifetime.Transient);
            var provider = service.BuildServiceProvider();
            TestContextFactory contextFactory = provider.GetRequiredService <TestContextFactory>();
            TestContext        context        = contextFactory.CreateDataContext();

            return(context);
        }
예제 #2
0
        public TestContext CreateBuilderContextFactoryByConfigFile()
        {
            IServiceCollection service = new ServiceCollection();

            service.AddDataContextFactory <TestContextFactory, TestContext>("lightdata2.json", config =>
            {
                config.ConfigName = "postgre2";
                config.SetCommandOutput(commandOutput);
            }, ServiceLifetime.Transient);
            var provider = service.BuildServiceProvider();
            TestContextFactory contextFactory = provider.GetRequiredService <TestContextFactory>();
            TestContext        context        = contextFactory.CreateDataContext();

            return(context);
        }
예제 #3
0
        public TestContext CreateBuilderContextFactoryByDiConfigSpecifiedDefault()
        {
            var builder = new ConfigurationBuilder();

            builder.AddJsonFile("appsettings.json");
            var configuration = builder.Build();

            IServiceCollection service = new ServiceCollection();

            service.AddDataContextFactory <TestContextFactory, TestContext>(configuration.GetSection("lightData"), config =>
            {
                config.SetCommandOutput(commandOutput);
            }, ServiceLifetime.Transient);
            var provider = service.BuildServiceProvider();
            TestContextFactory factory = provider.GetRequiredService <TestContextFactory>();
            TestContext        context = factory.CreateDataContext();

            return(context);
        }
예제 #4
0
        public TestContext CreateBuilderContextFactoryByDi()
        {
            IServiceCollection service = new ServiceCollection();

            service.AddDataContextFactory <TestContextFactory, TestContext>(builder =>
            {
                builder.UsePostgre("Server=postgre_test;Port=5432;UserId=postgres;Password=1qazxsw23edC;Database=LightData_Test;");
                builder.SetCommandOutput(commandOutput);
                builder.SetTimeout(2000);
                builder.SetBatchInsertCount(10);
                builder.SetBatchUpdateCount(10);
                builder.SetBatchDeleteCount(10);
            }, ServiceLifetime.Transient);
            var provider = service.BuildServiceProvider();
            TestContextFactory factory = provider.GetRequiredService <TestContextFactory>();
            TestContext        context = factory.CreateDataContext();

            return(context);
        }