Example #1
0
        public void CallingColumnExistsCanAcceptColumnNameWithSingleQuote()
        {
            var columnNameWithSingleQuote = quoter.Quote("i'd");

            using (var table = new PostgresTestTable(Processor, null, string.Format("{0} int", columnNameWithSingleQuote)))
                Processor.ColumnExists(null, table.Name, "i'd").ShouldBeTrue();
        }
Example #2
0
        public override void CallingColumnExistsCanAcceptColumnNameWithSingleQuote()
        {
            var columnNameWithSingleQuote = Quoter.Quote("i'd");

            using (var table = new PostgresTestTable(Processor, null, columnNameWithSingleQuote + " int"))
                Processor.ColumnExists(null, table.Name, "i'd").ShouldBeTrue();
        }
 public void CallingDefaultValueExistsCanAcceptSchemaNameWithSingleQuote()
 {
     using (var table = new PostgresTestTable(Processor, "test'schema", "id int"))
     {
         table.WithDefaultValueOn("id");
         Processor.DefaultValueExists("test'schema", table.Name, "id", 1).ShouldBeTrue();
     }
 }
 private void AddTestData(PostgresTestTable table)
 {
     for (int i = 0; i < 3; i++)
     {
         var cmd = table.Connection.CreateCommand();
         cmd.Transaction = table.Transaction;
         cmd.CommandText = string.Format("INSERT INTO {0} (id) VALUES ({1})", table.NameWithSchema, i);
         cmd.ExecuteNonQuery();
     }
 }
        public void CanReadDataWithSchema()
        {
            using (var table = new PostgresTestTable(Processor, "TestSchema", "id int"))
            {
                AddTestData(table);

                DataSet ds = Processor.Read("SELECT * FROM {0}", table.NameWithSchema);

                ds.ShouldNotBeNull();
                ds.Tables.Count.ShouldBe(1);
                ds.Tables[0].Rows.Count.ShouldBe(3);
                ds.Tables[0].Rows[2][0].ShouldBe(2);
            }
        }
        public override void CallingIndexExistsCanAcceptTableNameWithSingleQuote()
        {
            using (var table = new PostgresTestTable("Test'Table", Processor, null, "id int"))
            {
                var idxName = string.Format("\"idx_{0}\"", Quoter.UnQuote(table.Name));

                var cmd = table.Connection.CreateCommand();
                cmd.Transaction = table.Transaction;
                cmd.CommandText = string.Format("CREATE INDEX {0} ON \"{1}\" (id)", idxName, table.Name);
                cmd.ExecuteNonQuery();

                Processor.IndexExists(null, table.Name, idxName).ShouldBeTrue();
            }
        }
        public void CanReadTableData()
        {
            using (var table = new PostgresTestTable(Processor, null, "id int"))
            {
                AddTestData(table);

                DataSet ds = Processor.ReadTableData(null, table.Name);

                ds.ShouldNotBeNull();
                ds.Tables.Count.ShouldBe(1);
                ds.Tables[0].Rows.Count.ShouldBe(3);
                ds.Tables[0].Rows[2][0].ShouldBe(2);
            }
        }
        public void CanReadTableDataWithSchema()
        {
            using (var table = new PostgresTestTable(Processor, "TestSchema", "id int"))
            {
                AddTestData(table);

                DataSet ds = ((DataSetContainer)Processor.ReadTableData("TestSchema", table.Name)).DataSet;

                ds.ShouldNotBeNull();
                ds.Tables.Count.ShouldBe(1);
                ds.Tables[0].Rows.Count.ShouldBe(3);
                ds.Tables[0].Rows[2][0].ShouldBe(2);
            }
        }
        public override void CallingIndexExistsReturnsTrueIfIndexExistsWithSchema()
        {
            using (var table = new PostgresTestTable(Processor, "TestSchema", "id int"))
            {
                var idxName = string.Format("\"idx_{0}\"", Quoter.UnQuote(table.Name));

                var cmd = table.Connection.CreateCommand();
                cmd.Transaction = table.Transaction;
                cmd.CommandText = string.Format("CREATE INDEX {0} ON {1} (id)", idxName, table.NameWithSchema);
                cmd.ExecuteNonQuery();

                Processor.IndexExists("TestSchema", table.Name, idxName).ShouldBeTrue();
            }
        }
        public override void CallingIndexExistsCanAcceptIndexNameWithSingleQuote()
        {
            using (var table = new PostgresTestTable(Processor, null, "id int"))
            {
                var idxName = $"\"id'x_{Quoter.UnQuote(table.Name)}\"";

                var cmd = table.Connection.CreateCommand();
                cmd.Transaction = table.Transaction;
                cmd.CommandText = $"CREATE INDEX {idxName} ON \"{table.Name}\" (id)";
                cmd.ExecuteNonQuery();

                Processor.IndexExists(null, table.Name, idxName).ShouldBeTrue();
            }
        }
        public void CanReadData()
        {
            using (var table = new PostgresTestTable(Processor, null, "id int"))
            {
                AddTestData(table);

                DataSet ds = ((DataSetContainer)Processor.Read("SELECT * FROM {0}", table.Name)).DataSet;

                ds.ShouldNotBeNull();
                ds.Tables.Count.ShouldBe(1);
                ds.Tables[0].Rows.Count.ShouldBe(3);
                ds.Tables[0].Rows[2][0].ShouldBe(2);
            }
        }
 public override void CallingConstraintExistsReturnsTrueIfConstraintExistsWithSchema()
 {
     using (var table = new PostgresTestTable(Processor, "TestSchema", "id int", "wibble int CONSTRAINT c1 CHECK(wibble > 0)"))
         Processor.ConstraintExists("TestSchema", table.Name, "c1").ShouldBeTrue();
 }
 public override void CallingConstraintExistsReturnsFalseIfConstraintDoesNotExist()
 {
     using (var table = new PostgresTestTable(Processor, null, "id int"))
         Processor.ConstraintExists(null, table.Name, "DoesNotExist").ShouldBeFalse();
 }
 public override void CallingConstraintExistsCanAcceptTableNameWithSingleQuote()
 {
     using (var table = new PostgresTestTable("Test'Table", Processor, null, "id int", "wibble int CONSTRAINT c1 CHECK(wibble > 0)"))
         Processor.ConstraintExists(null, table.Name, "c1").ShouldBeTrue();
 }
 public override void CallingConstraintExistsCanAcceptConstraintNameWithSingleQuote()
 {
     using (var table = new PostgresTestTable(Processor, null, "id int", string.Format("wibble int CONSTRAINT {0} CHECK(wibble > 0)", Quoter.QuoteConstraintName("c'1"))))
         Processor.ConstraintExists(null, table.Name, "c'1").ShouldBeTrue();
 }
Example #16
0
 public void CallingContraintExistsReturnsTrueIfConstraintExists()
 {
     using (var table = new PostgresTestTable(Processor, null, "id int", "wibble int CONSTRAINT c1 CHECK(wibble > 0)"))
         Processor.ConstraintExists(null, table.Name, "c1").ShouldBeTrue();
 }
Example #17
0
 public void CallingConstraintExistsReturnsFalseIfConstraintDoesNotExistWithSchema()
 {
     using (var table = new PostgresTestTable(Processor, "TestSchema", "id int"))
         Processor.ConstraintExists("TestSchema", table.Name, "DoesNotExist").ShouldBeFalse();
 }
Example #18
0
 public void CallingColumnExistsCanAcceptSchemaNameWithSingleQuote()
 {
     using (var table = new PostgresTestTable("Test'Schema", "TestSingle'Quote", Processor, "id int"))
         Processor.ColumnExists("Test'Schema", table.Name, "id").ShouldBeTrue();
 }
 public override void CallingTableExistsReturnsTrueIfTableExists()
 {
     using (var table = new PostgresTestTable(Processor, null, "id int"))
         Processor.TableExists(null, table.Name).ShouldBeTrue();
 }
 public override void CallingIndexExistsReturnsFalseIfIndexDoesNotExistWithSchema()
 {
     using (var table = new PostgresTestTable(Processor, "TestSchema", "id int"))
         Processor.IndexExists("TestSchema", table.Name, "DoesNotExist").ShouldBeFalse();
 }
Example #21
0
 public void CallingIndexExistsReturnsFalseIfIndexDoesNotExist()
 {
     using (var table = new PostgresTestTable(Processor, null, "id int"))
         Processor.IndexExists(null, table.Name, "DoesNotExist").ShouldBeFalse();
 }
Example #22
0
 public void CallingColumnExistsReturnsTrueIfColumnExists()
 {
     using (var table = new PostgresTestTable(Processor, null, "id int"))
         Processor.ColumnExists(null, table.Name, "id").ShouldBeTrue();
 }
 public override void CallingTableExistsCanAcceptSchemaNameWithSingleQuote()
 {
     using (var table = new PostgresTestTable(Processor, "Test'Schema", "id int"))
         Processor.TableExists("Test'Schema", table.Name).ShouldBeTrue();
 }
Example #24
0
 public void CallingColumnExistsReturnsTrueIfColumnExistsWithSchema()
 {
     using (var table = new PostgresTestTable(Processor, "TestSchema", "id int"))
         Processor.ColumnExists("TestSchema", table.Name, "id").ShouldBeTrue();
 }
Example #25
0
 public void CallingConstraintExistsCanAcceptSchemaNameWithSingleQuote()
 {
     using (var table = new PostgresTestTable(Processor, "Test'Schema", "id int", "wibble int CONSTRAINT c1 CHECK(wibble > 0)"))
         Processor.ConstraintExists("Test'Schema", table.Name, "c1").ShouldBeTrue();
 }
 public override void CallingTableExistsCanAcceptTableNameWithSingleQuote()
 {
     using (var table = new PostgresTestTable("Test'Table", Processor, null, "id int"))
         Processor.TableExists(null, table.Name).ShouldBeTrue();
 }
 public void CallingConstraintExistsReturnsFalseIfConstraintExistsInDifferentSchema()
 {
     using (var table = new PostgresTestTable(Processor, "TestSchema1", "id int", "wibble int CONSTRAINT c1 CHECK(wibble > 0)"))
         Processor.ConstraintExists("TestSchema2", table.Name, "c1").ShouldBeFalse();
 }
 public override void CallingTableExistsReturnsTrueIfTableExistsWithSchema()
 {
     using (var table = new PostgresTestTable(Processor, "TestSchema", "id int"))
         Processor.TableExists("TestSchema", table.Name).ShouldBeTrue();
 }
 public void CallingTableExistsReturnsFalseIfTableExistsInDifferentSchema()
 {
     using (var table = new PostgresTestTable(Processor, "TestSchema1", "id int"))
         Processor.TableExists("TestSchema2", table.Name).ShouldBeFalse();
 }