private void AddTestData(FirebirdTestTable table) { for (int i = 0; i < 3; i++) { using (var cmd = table.Connection.CreateCommand()) { cmd.Transaction = table.Transaction; cmd.CommandText = string.Format("INSERT INTO {0} (id) VALUES ({1})", Quoter.QuoteTableName(table.Name), i); cmd.ExecuteNonQuery(); } } Processor.AutoCommit(); }
public void CanReadTableData() { using (var table = new FirebirdTestTable(Processor, null, "id int")) { Processor.CheckTable(table.Name); AddTestData(table); using (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 override void CallingIndexExistsCanAcceptTableNameWithSingleQuote() { using (var table = new FirebirdTestTable("\"Test'Table\"", Processor, null, "id int")) { Processor.CheckTable(table.Name); Processor.LockTable(table.Name); var idxName = "\"idx_Test'Table\""; using (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.AutoCommit(); Processor.IndexExists(null, table.Name, idxName).ShouldBeTrue(); } }
public override void CallingTableExistsReturnsTrueIfTableExists() { using (var table = new FirebirdTestTable(Processor, null, "id int")) Processor.TableExists(null, table.Name).ShouldBeTrue(); }
public void CanCreateTrigger() { using (var table = new FirebirdTestTable(Processor, null, "id int")) { Processor.Process(Processor.CreateTriggerExpression(table.Name, "TestTrigger", true, TriggerEvent.Insert, "as begin end")); Processor.TriggerExists(String.Empty, table.Name, "TestTrigger").ShouldBeTrue(); } }
public void IdentityCanDropIdentityColumn() { using (var table = new FirebirdTestTable(Processor, null, "bogus int")) { Processor.Process(new CreateColumnExpression { TableName = table.Name, Column = { Name = "id", IsIdentity = true, Type = DbType.Int64 } }); Processor.ColumnExists(String.Empty, table.Name, "id").ShouldBeTrue(); Processor.SequenceExists(String.Empty, String.Format("gen_{0}_id", table.Name)).ShouldBeTrue(); Processor.TriggerExists(String.Empty, table.Name, String.Format("gen_id_{0}_id", table.Name)).ShouldBeTrue(); Processor.Process(new DeleteColumnExpression { TableName = table.Name, ColumnNames = { "id" } }); Processor.ColumnExists(String.Empty, table.Name, "id").ShouldBeFalse(); Processor.SequenceExists(String.Empty, String.Format("gen_{0}_id", table.Name)).ShouldBeFalse(); Processor.TriggerExists(String.Empty, table.Name, String.Format("gen_id_{0}_id", table.Name)).ShouldBeFalse(); } }
public void CanReadData() { using (var table = new FirebirdTestTable(Processor, null, "id int")) { Processor.CheckTable(table.Name); AddTestData(table); using (DataSet ds = ((DataSetContainer)Processor.Read("SELECT * FROM {0}", Quoter.QuoteTableName(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 CallingConstraintExistsReturnsFalseIfConstraintDoesNotExistWithSchema() { using (var table = new FirebirdTestTable(Processor, "TestSchema", "id int")) Processor.ConstraintExists("TestSchema", table.Name, "DoesNotExist").ShouldBeFalse(); }
public override void CallingConstraintExistsCanAcceptConstraintNameWithSingleQuote() { using (var table = new FirebirdTestTable(Processor, null, "id int", string.Format("wibble int CONSTRAINT {0} CHECK(wibble > 0)", "\"c'1\""))) Processor.ConstraintExists(null, table.Name, "\"c'1\"").ShouldBeTrue(); }
public void CallingIndexExistsReturnsTrueIfIndexExistsWithSchema() { using (var table = new FirebirdTestTable(Processor, "TestSchema", "id int")) { Processor.CheckTable(table.Name); Processor.LockTable(table.Name); var idxName = string.Format("idx_{0}", table.Name); using (var cmd = table.Connection.CreateCommand()) { cmd.Transaction = table.Transaction; cmd.CommandText = string.Format("CREATE INDEX {0} ON {1} (id)", quoter.QuoteIndexName(idxName), quoter.QuoteTableName(table.Name)); cmd.ExecuteNonQuery(); } Processor.AutoCommit(); Processor.IndexExists("TestSchema", table.Name, idxName).ShouldBeTrue(); } }
public void CallingIndexExistsReturnsFalseIfIndexDoesNotExistWithSchema() { using (var table = new FirebirdTestTable(Processor, "TestSchema", "id int")) Processor.IndexExists("TestSchema", table.Name, "DoesNotExist").ShouldBeFalse(); }
public void CallingContraintExistsReturnsTrueIfConstraintExists() { using (var table = new FirebirdTestTable(Processor, null, "id int", "wibble int CONSTRAINT c1 CHECK(wibble > 0)")) Processor.ConstraintExists(null, table.Name, "C1").ShouldBeTrue(); }
public void CallingConstraintExistsCanAcceptTableNameWithSingleQuote() { using (var table = new FirebirdTestTable("TestSchema", "TestSingle'Quote", Processor, "id int", "wibble int CONSTRAINT c1 CHECK(wibble > 0)")) Processor.ConstraintExists("TestSchema", table.Name, "C1").ShouldBeTrue(); }
public void CallingColumnExistsReturnsTrueIfColumnExistsWithSchema() { using (var table = new FirebirdTestTable(Processor, "TestSchema", "id int")) Processor.ColumnExists("TestSchema", table.Name, "ID").ShouldBeTrue(); }
public override void CallingIndexExistsReturnsFalseIfIndexDoesNotExist() { using (var table = new FirebirdTestTable(Processor, null, "id int")) Processor.IndexExists(null, table.Name, "DoesNotExist").ShouldBeFalse(); }
public void CallingColumnExistsReturnsFalseIfColumnDoesNotExist() { using (var table = new FirebirdTestTable(Processor, null, "id int")) Processor.ColumnExists(null, table.Name, "DoesNotExist").ShouldBeFalse(); }
public void CallingColumnExistsReturnsTrueIfColumnExists() { using (var table = new FirebirdTestTable(Processor, null, "id int")) Processor.ColumnExists(null, table.Name, "ID").ShouldBeTrue(); }
public void CallingTableExistsCanAcceptSchemaNameWithSingleQuote() { using (var table = new FirebirdTestTable(Processor, "Test'Schema", "id int")) Processor.TableExists("Test'Schema", table.Name).ShouldBeTrue(); }
public override void CallingConstraintExistsCanAcceptTableNameWithSingleQuote() { using (var table = new FirebirdTestTable("\"Test'Table\"", Processor, null, "id int", "wibble int CONSTRAINT c1 CHECK(wibble > 0)")) Processor.ConstraintExists(null, table.Name, "C1").ShouldBeTrue(); }
public void CallingTableExistsCanAcceptTableNameWithSingleQuote() { using (var table = new FirebirdTestTable(null, "TestSingle'Quote", Processor, "id int")) Processor.TableExists(null, table.Name).ShouldBeTrue(); }
public override void CallingConstraintExistsReturnsTrueIfConstraintExistsWithSchema() { using (var table = new FirebirdTestTable(Processor, "TestSchema", "id int", "wibble int CONSTRAINT C1 CHECK(wibble > 0)")) Processor.ConstraintExists("TestSchema", table.Name, "C1").ShouldBeTrue(); }
public void CanAlterSequence() { using (var table = new FirebirdTestTable(Processor, null, "id int")) { Processor.Process(new CreateSequenceExpression() { Sequence = { Name = "Sequence", StartWith = 6 } }); using (DataSet ds = Processor.Read("SELECT GEN_ID(\"Sequence\", 1) as generated_value FROM RDB$DATABASE")) { ds.Tables[0].ShouldNotBeNull(); ds.Tables[0].Rows[0].ShouldNotBeNull(); ds.Tables[0].Rows[0]["generated_value"].ShouldBe(7); } Processor.Process(new DeleteSequenceExpression() { SequenceName = "Sequence" }); Processor.SequenceExists(String.Empty, table.Name, "Sequence").ShouldBeFalse(); } }
public void CanReadTableDataWithSchema() { using (var table = new FirebirdTestTable(Processor, "TestSchema", "id int")) { Processor.CheckTable(table.Name); AddTestData(table); using (var 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 void CanCreateAndDropSequenceWithExistCheck() { using (var table = new FirebirdTestTable(Processor, null, "id int")) { Processor.Process(new CreateSequenceExpression() { Sequence = { Name = "Sequence" } }); Processor.SequenceExists("", "", "Sequence").ShouldBeTrue(); Processor.Process(new DeleteSequenceExpression() { SequenceName = "Sequence" }); Processor.SequenceExists("", "", "Sequence").ShouldBeFalse(); } }
public void IdentityCanInsertMultiple() { using (var table = new FirebirdTestTable(Processor, null, "bogus int")) { Processor.Process(new CreateColumnExpression { TableName = table.Name, Column = { Name = "id", IsIdentity = true, Type = DbType.Int64, IsPrimaryKey = true } }); var insert = new InsertDataExpression { TableName = table.Name }; var item = new Model.InsertionDataDefinition(); item.Add(new System.Collections.Generic.KeyValuePair<string, object>("BOGUS", 0)); insert.Rows.Add(item); //Process 5 times = insert 5 times Processor.Process(insert); Processor.Process(insert); Processor.Process(insert); Processor.Process(insert); Processor.Process(insert); using (DataSet ds = ((DataSetContainer)Processor.ReadTableData(String.Empty, table.Name)).DataSet) { ds.Tables.Count.ShouldBe(1); ds.Tables[0].Rows.Count.ShouldBe(5); ds.Tables[0].Rows[0]["BOGUS"].ShouldBe(0); ds.Tables[0].Rows[0]["id"].ShouldBe(1); ds.Tables[0].Rows[1]["id"].ShouldBe(2); ds.Tables[0].Rows[2]["id"].ShouldBe(3); ds.Tables[0].Rows[3]["id"].ShouldBe(4); ds.Tables[0].Rows[4]["id"].ShouldBe(5); } } }
public void CallingColumnExistsCanAcceptColumnNameWithSingleQuote() { var columnNameWithSingleQuote = quoter.QuoteColumnName("i'd"); using (var table = new FirebirdTestTable(Processor, null, string.Format("{0} int", columnNameWithSingleQuote))) Processor.ColumnExists(null, table.Name, "i'd").ShouldBeTrue(); }
public override void CallingTableExistsCanAcceptTableNameWithSingleQuote() { using (var table = new FirebirdTestTable("\"Test'Table\"", Processor, null, "id int")) Processor.TableExists(null, table.Name).ShouldBeTrue(); }
public void IdentityCanInsertMultiple() { using (var table = new FirebirdTestTable(Processor, null, "bogus int")) { Processor.Process(new CreateColumnExpression() { TableName = table.Name, Column = { Name = "id", IsIdentity = true, Type = DbType.Int64, IsPrimaryKey = true } }); InsertDataExpression insert = new InsertDataExpression() { TableName = table.Name }; Model.ExplicitDataDefinition item = new Model.ExplicitDataDefinition(new DataValue("BOGUS", 0)); insert.Rows.Add(item); //Process 5 times = insert 5 times Processor.Process(insert); Processor.Process(insert); Processor.Process(insert); Processor.Process(insert); Processor.Process(insert); using (DataSet ds = Processor.ReadTableData(String.Empty, table.Name)) { ds.Tables.Count.ShouldBe(1); ds.Tables[0].Rows.Count.ShouldBe(5); ds.Tables[0].Rows[0]["BOGUS"].ShouldBe(0); ds.Tables[0].Rows[0]["id"].ShouldBe(1); ds.Tables[0].Rows[1]["id"].ShouldBe(2); ds.Tables[0].Rows[2]["id"].ShouldBe(3); ds.Tables[0].Rows[3]["id"].ShouldBe(4); ds.Tables[0].Rows[4]["id"].ShouldBe(5); } } }
public override void CallingTableExistsReturnsTrueIfTableExistsWithSchema() { using (var table = new FirebirdTestTable(Processor, "TestSchema", "id int")) Processor.TableExists("TestSchema", table.Name).ShouldBeTrue(); }
public void CallingColumnExistsCanAcceptTableNameWithSingleQuote() { using (var table = new FirebirdTestTable("TestSchema", "TestSingle'Quote", Processor, "id int")) Processor.ColumnExists("TestSchema", table.Name, "ID").ShouldBeTrue(); }