예제 #1
0
        public static void Initialize(TestContext _)
        {
            var builder = new ConfigurationBuilder()
                          .SetBasePath(Directory.GetCurrentDirectory())
                          .AddJsonFile("testsettings.json");

            var configuration = builder.Build();

            configuration.GetSection("DBSettings").Bind(DBSettings);
            DBSettings.SqlProviderFactory = SqlClientFactory.Instance;

            DataConfiguration.Initialize();
            var setup = new DataSetup(DBSettings);

            setup.Initialize();
            setup.LoadUnitTestData();

            WebApiFactory = new WebApplicationFactory <Startup>()
                            .WithWebHostBuilder(builder =>
            {
                builder.ConfigureTestServices(services =>
                {
                    services.Configure <DBSettings>(options =>
                    {
                        options.StorageConnectionString    = DBSettings.StorageConnectionString;
                        options.SqlConnectionString        = DBSettings.SqlConnectionString;
                        options.ReplicaSqlConnectionString = DBSettings.ReplicaSqlConnectionString;
                    });
                });
            });

            StartupWebApiProject();
        }
예제 #2
0
        public IActionResult Initialize()
        {
            var setup = new DataSetup(_dbSettings);

            setup.Initialize();
            return(new OkResult());
        }