Esempio n. 1
0
        public void DeriveParameters()
        {
            using (HsqlConnection connection = NewConnection())
                using (HsqlCommand testSubject = connection.CreateCommand())
                {
                    testSubject.CommandText = "call 1 + cast(? as integer)";
                    testSubject.CommandType = global::System.Data.CommandType.StoredProcedure;
                    testSubject.DeriveParameters();

                    HsqlParameterCollection parameters = testSubject.Parameters;

                    Assert.AreEqual(1, parameters.Count);

                    HsqlParameter parameter = parameters[0];

                    Assert.AreEqual(DbType.Int32, parameter.DbType);
                    Assert.AreEqual(ParameterDirection.Input, parameter.Direction);
                    Assert.AreEqual(false, parameter.IsNullable);
                    Assert.AreEqual(0, parameter.Offset);
                    Assert.AreEqual("@p1", parameter.ParameterName);
                    Assert.AreEqual(10, parameter.Precision);
                    Assert.AreEqual(HsqlProviderType.Integer, parameter.ProviderType);
                    Assert.AreEqual(0, parameter.Scale);
                    Assert.AreEqual(4, parameter.Size);
                    Assert.AreEqual("", parameter.SourceColumn);
                    Assert.AreEqual(false, parameter.SourceColumnNullMapping);
                    Assert.AreEqual(DataRowVersion.Default, parameter.SourceVersion);
                    Assert.AreEqual("NULL", parameter.ToSqlLiteral());
                    Assert.AreEqual(null, parameter.Value);
                }
        }
Esempio n. 2
0
        public void CommandType()
        {
            using (HsqlConnection connection = NewConnection())
                using (HsqlCommand testSubject = connection.CreateCommand())
                {
                    CommandType actual = testSubject.CommandType;

                    Assert.AreEqual(System.Data.CommandType.Text, actual);

                    testSubject.CommandType = System.Data.CommandType.StoredProcedure;

                    Assert.AreEqual(System.Data.CommandType.StoredProcedure, actual);

                    testSubject.CommandType = System.Data.CommandType.TableDirect;

                    Assert.AreEqual(System.Data.CommandType.TableDirect, actual);

                    Common.HsqlWarningEventArgs warning = null;

                    testSubject.Warning += delegate(object sender, Common.HsqlWarningEventArgs args) {
                        warning = args;
                    };

                    testSubject.CommandType = (CommandType)100;

                    Assert.IsNotNull(warning);

                    Assert.AreEqual(System.Data.CommandType.Text, actual);
                }
        }
Esempio n. 3
0
 public void Cancel()
 {
     using (HsqlConnection connection = NewConnection())
         using (HsqlCommand testSubject = connection.CreateCommand())
         {
             testSubject.Cancel(); // no-op.
         }
 }
Esempio n. 4
0
 public void AddBatch()
 {
     using (HsqlConnection connection = NewConnection())
         using (HsqlCommand testSubject = connection.CreateCommand())
         {
             testSubject.AddBatch();
             //testSubject.C
         }
 }
Esempio n. 5
0
 public void CreateParameter()
 {
     using (HsqlConnection connection = NewConnection())
         using (HsqlCommand testSubject = connection.CreateCommand())
         {
             HsqlParameter parameter    = testSubject.CreateParameter();
             IDbParmeter   idbparameter = (testSubject as IDbCommand).CreateParameter();
             DbParameter   dbparameter  = (testSubject as DbCommand).CreateParameter();
         }
 }
Esempio n. 6
0
 public virtual void ExecuteNonQuery()
 {
     using (HsqlConnection connection = NewConnection())
         using (HsqlCommand testSubject = connection.CreateCommand())
         {
             testSubject.CommandText = ";";
             int expected = 0;
             int actual   = testSubject.ExecuteNonQuery();
             Assert.AreEqual(expected, actual);
         }
 }
Esempio n. 7
0
        public void CommandTimeout()
        {
            using (HsqlConnection connection = NewConnection())
                using (HsqlCommand testSubject = connection.CreateCommand())
                {
                    int actual = testSubject.CommandTimeout;


                    Assert.AreEqual(30, actual);
                }
        }
Esempio n. 8
0
        public virtual void ExecuteScalar()
        {
            using (HsqlConnection connection = NewConnection())
                using (HsqlCommand testSubject = connection.CreateCommand())
                {
                    testSubject.CommandText = "call database();";
                    object expected = "mem:test";
                    object actual   = testSubject.ExecuteScalar();

                    Assert.AreEqual(expected, actual);
                }
        }
Esempio n. 9
0
        public virtual void UpdatedRowSource()
        {
            using (HsqlConnection connection = NewConnection())
                using (HsqlCommand testSubject = connection.CreateCommand())
                {
                    UpdateRowSource expected = UpdateRowSource.Both;
                    UpdateRowSource actual   = testSubject.UpdatedRowSource;

                    Assert.AreEqual(expected, actual);

                    Assert.Fail("TODO");
                }
        }
Esempio n. 10
0
        public virtual void Prepare()
        {
            using (HsqlConnection connection = NewConnection())
                using (HsqlCommand testSubject = connection.CreateCommand())
                {
                    testSubject.CommandText = "select * from information_schema.system_tables";
                    testSubject.Prepare();

                    bool expected = true;
                    bool actual   = testSubject.IsPrepared;

                    Assert.AreEqual(expected, actual);
                }
        }
Esempio n. 11
0
        public virtual void StatementCompleted()
        {
            using (HsqlConnection connection = NewConnection())
                using (HsqlCommand testSubject = connection.CreateCommand())
                {
                    testSubject.StatementCompleted += delegate(object sender, StatementCompletedEventArgs e)
                    {
                        Assert.AreNotSame(testSubject, sender);
                        Assert.AreEqual(0, e.RecordCount);
                    };

                    //
                    Assert.Fail("TODO");
                }
        }
Esempio n. 12
0
        public virtual void CreateCommand()
        {
            using (HsqlConnection testSubject = new HsqlConnection())
            {
                HsqlCommand command = testSubject.CreateCommand();

                Assert.AreSame(testSubject, command.Connection);
                Assert.AreEqual(string.Empty, command.CommandText);
                Assert.AreEqual(CommandType.Text, command.CommandType);
                Assert.AreEqual(true, command.DesignTimeVisible);
                Assert.AreEqual(false, command.IsPrepared);
                Assert.AreEqual(UpdateRowSource.Both, command.UpdatedRowSource);
                Assert.AreEqual(null, command.Transaction);
            }
        }
Esempio n. 13
0
        public void CommandText()
        {
            using (HsqlConnection connection = NewConnection())
                using (HsqlCommand testSubject = connection.CreateCommand())
                {
                    Assert.AreEqual(string.Empty, testSubject.CommandText);

                    testSubject.CommandText = "select * from information_schema.system_tables";

                    Assert.AreEqual("select * from information_schema.system_tables", testSubject.CommandText);

                    testSubject.CommandText = null;

                    Assert.AreEqual(string.Empty, testSubject.CommandText);
                }
        }
Esempio n. 14
0
        public void ExecuteReader()
        {
            using (HsqlConnection connection = NewConnection())
                using (HsqlCommand testSubject = connection.CreateCommand())
                {
                    testSubject.CommandText = "select * from information_schema.system_tables";

                    using (HsqlDataReader reader = testSubject.ExecuteReader())
                    {
                        object[] values = new object[reader.FieldCount];

                        while (reader.Read())
                        {
                            int fieldCount = reader.GetValues(values);

                            for (int i = 0; i < fieldCount; i++)
                            {
                                object value = values[i];
                                Console.Write(value);
                                Console.Write(" : ");
                            }
                            Console.WriteLine();
                        }
                    }
                }

            using (HsqlConnection connection = NewConnection())
                using (HsqlCommand testSubject = connection.CreateCommand())
                {
                    testSubject.CommandText = "select * from information_schema.system_tables";
                    HsqlDataReader reader      = testSubject.ExecuteReader(CommandBehavior.SchemaOnly);
                    DataTable      schemaTable = reader.GetSchemaTable();

                    foreach (DataRow row in schemaTable.Rows)
                    {
                        object[] values = row.ItemArray;

                        foreach (object value in values)
                        {
                            Console.Write(value);
                            Console.Write(" : ");
                        }
                        Console.WriteLine();
                    }
                }
        }
Esempio n. 15
0
        public virtual void Transaction()
        {
            using (HsqlConnection connection = NewConnection())
                using (HsqlCommand testSubject = connection.CreateCommand())
                {
                    testSubject.CommandText = "update foo set bar = baz";
                    testSubject.Connection.BeginTransaction(IsolationLevel.ReadUncommitted);
                    HsqlTransaction transaction = testSubject.Transaction;

                    IsolationLevel expected = IsolationLevel.ReadUncommitted;
                    IsolationLevel actual   = transaction.IsolationLevel;

                    Assert.AreEqual(expected, actual);

                    //
                    Assert.Fail("TODO");
                }
        }
Esempio n. 16
0
        public void Clone()
        {
            using (HsqlConnection connection = NewConnection())
                using (HsqlTransaction transaction = connection.BeginTransaction())
                    using (HsqlCommand originalCommand = connection.CreateCommand())
                    {
                        originalCommand.CommandType = global::System.Data.CommandType.StoredProcedure;
                        originalCommand.CommandText = "call 1 + cast(? as integer)";
                        originalCommand.DeriveParameters();

                        HsqlCommand clonedCommand = originalCommand.Clone();

                        Assert.AreEqual(originalCommand.CommandText, clonedCommand.CommandText);
                        Assert.AreEqual(originalCommand.CommandTimeout, clonedCommand.CommandTimeout);
                        Assert.AreEqual(originalCommand.CommandType, clonedCommand.CommandType);
                        Assert.AreSame(connection, clonedCommand.Connection);
                        Assert.AreEqual(originalCommand.DesignTimeVisible, clonedCommand.DesignTimeVisible);
                        Assert.AreEqual(originalCommand.Parameters.Count, clonedCommand.Parameters.Count);

                        for (int i = 0; i < originalCommand.Parameters.Count; i++)
                        {
                            HsqlParameter orignalCommandParameter = originalCommand.Parameters[i];
                            HsqlParameter clonedCommandParameter  = clonedCommand.Parameters[i];

                            Assert.AreEqual(orignalCommandParameter.DbType, clonedCommandParameter.DbType);
                            Assert.AreEqual(orignalCommandParameter.Direction, clonedCommandParameter.Direction);
                            Assert.AreEqual(orignalCommandParameter.IsNullable, clonedCommandParameter.IsNullable);
                            Assert.AreEqual(orignalCommandParameter.Offset, clonedCommandParameter.Offset);
                            Assert.AreEqual(orignalCommandParameter.ParameterName, clonedCommandParameter.ParameterName);
                            Assert.AreEqual(orignalCommandParameter.Precision, clonedCommandParameter.Precision);
                            Assert.AreEqual(orignalCommandParameter.ProviderType, clonedCommandParameter.ProviderType);
                            Assert.AreEqual(orignalCommandParameter.Scale, clonedCommandParameter.Scale);
                            Assert.AreEqual(orignalCommandParameter.Size, clonedCommandParameter.Size);
                            Assert.AreEqual(orignalCommandParameter.SourceColumn, clonedCommandParameter.SourceColumn);
                            Assert.AreEqual(orignalCommandParameter.SourceColumnNullMapping, clonedCommandParameter.SourceColumnNullMapping);
                            Assert.AreEqual(orignalCommandParameter.SourceVersion, clonedCommandParameter.SourceVersion);
                            Assert.AreEqual(orignalCommandParameter.ToSqlLiteral(), clonedCommandParameter.ToSqlLiteral());
                            Assert.AreEqual(orignalCommandParameter.Value, clonedCommandParameter.Value);
                        }

                        Assert.AreSame(originalCommand.Transaction, clonedCommand.Transaction);
                        Assert.AreEqual(originalCommand.UpdatedRowSource, clonedCommand.UpdatedRowSource);
                    }
        }