Exemplo n.º 1
0
        public void Execute_create_and_drop_schema_table(string connectionString, DatabaseProvider provider)
        {
            //Arrange
            const string schema  = "minimigtest2";
            const string table   = "minimigtabletest";
            var          options = new Options()
            {
                ConnectionString = connectionString, Provider = provider, MigrationsTableSchema = schema, MigrationsTable = table
            };

            //Act
            using var context = new ConnectionContext(options);
            context.Open();
            context.BeginTransaction();
            context.ExecuteCommand($"Create schema {schema}");
            context.Commit();
            bool existsSchema = context.SchemaMigrationExists();

            context.CreateMigrationsTable();
            bool existsTable = context.SchemaMigrationExists();

            //Clean Up
            context.DropMigrationsTable();
            context.ExecuteCommand($"Drop schema {schema}");
            context.Dispose();

            //Assert
            Assert.Equal(ConnectionState.Closed, context.Connection.State);
            Assert.True(existsSchema);
            Assert.True(existsTable);
        }
Exemplo n.º 2
0
        public void Execute_command_connection(string connectionString, DatabaseProvider provider)
        {
            //Arrange
            var options = new Options()
            {
                ConnectionString = connectionString, Provider = provider
            };

            //Act
            using var context = new ConnectionContext(options);
            context.Open();
            context.ExecuteCommand("SELECT 1");

            //Assert
            Assert.Equal(ConnectionState.Open, context.Connection.State);
        }