public void InitDatabaseForIdGenerator()
        {
            var kormBuilder = new KormBuilder(new ServiceCollection(), ServerHelper.Connection.ConnectionString);

            kormBuilder.InitDatabaseForIdGenerator();

            CheckTableAndProcedure();
        }
Exemple #2
0
        public void InitDatabaseForIdGenerator()
        {
            KormBuilder kormBuilder = CreateKormBuilder();

            kormBuilder.InitDatabaseForIdGenerator();

            CheckTableAndProcedure();
        }
Exemple #3
0
        public void UseDefaultConnectionStringIfConfigurationIsProvided()
        {
            IConfigurationRoot configuration = ConfigurationHelper.GetConfiguration();
            var services = new ServiceCollection();

            KormBuilder builder = services.AddKorm(configuration);

            builder.ConnectionSettings.ConnectionString.Should().Be(configuration.GetConnectionString("DefaultConnection"));
        }
Exemple #4
0
        public void UseDatabaseConfiguration()
        {
            KormBuilder kormBuilder = CreateKormBuilder(false);
            DatabaseConfigurationBase configuration = Substitute.For <DatabaseConfigurationBase>();

            kormBuilder.UseDatabaseConfiguration(configuration);
            IDatabase database = kormBuilder.Build();

            database.Should().NotBeNull();
            configuration.Received().OnModelCreating(Arg.Any <ModelConfigurationBuilder>());
        }
Exemple #5
0
        private KormBuilder CreateKormBuilder()
        {
            var connectionSettings = new ConnectionStringSettings(
                "Default",
                ServerHelper.Connection.ConnectionString,
                "System.Data.SqlClient");

            var kormBuilder = new KormBuilder(new ServiceCollection(), connectionSettings);

            return(kormBuilder);
        }
Exemple #6
0
        public void InitDatabaseForIdGenerator()
        {
            var connectionSettings = new ConnectionStringSettings(
                "Default",
                ServerHelper.Connection.ConnectionString,
                "System.Data.SqlClient");

            var kormBuilder = new KormBuilder(new ServiceCollection(), connectionSettings);

            kormBuilder.InitDatabaseForIdGenerator();

            CheckTableAndProcedure();
        }
Exemple #7
0
        private static void Migrate(KormBuilder kormBuilder)
        {
            var policy = Policy
                         .Handle <SqlException>()
                         .OrInner <SocketException>()
                         .OrInner <SqlException>()
                         .WaitAndRetry(10, retryAttempt =>
            {
                Console.WriteLine($"=== Migrate retry attempt: {retryAttempt}");
                return(TimeSpan.FromSeconds(2));
            });

            policy.Execute(kormBuilder.Migrate);
        }
Exemple #8
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSwaggerDocumentation(Configuration);

            services.AddTransient <IOrderRepository, OrderRepository>();
            services.AddTransient <DummyDataInitializer>();
            services.AddControllers();

            KormBuilder kormBuilder = services.AddKorm(Configuration)
                                      .UseDatabaseConfiguration <DatabaseConfiguration>()
                                      .AddKormMigrations();

            Migrate(kormBuilder);
        }