Example #1
0
 public void TestDatabaseProvider()
 {
     string[] providers = TestUtil.Providers;
     for (int i = 0; i < providers.Length; ++i)
     {
         GlazeFactory glazeFactory = new GlazeFactory(providers[i]);
         GlazeCommand glazeCommand = (GlazeCommand)(glazeFactory.CreateCommand());
         Assert.AreEqual(providers[i], glazeCommand.DatabaseProvider);
     }
 }
Example #2
0
 public void TestCreateCommand()
 {
     string[] providers = TestUtil.Providers;
     for (int i = 0; i < providers.Length; ++i)
     {
         GlazeFactory glazeFactory = new GlazeFactory(providers[i]);
         DbCommand    command      = glazeFactory.CreateCommand();
         GlazeCommand glazeCommand = command as GlazeCommand;
         Assert.IsNotNull(glazeCommand);
     }
 }
Example #3
0
        void CheckDelete(DbConnection connection)
        {
            GlazeCommand command = (GlazeCommand)(connection.CreateCommand());

            command.CommandText = "delete from table1 where 0=1";
            int c = command.ExecuteNonQuery();

            Assert.AreEqual(0, c);

            c = command.ExecuteNonQuery();
            Assert.AreEqual(0, c);
        }
Example #4
0
        public GlazeCommand MakeSchemaQuery(GlazeConnection cnn,
                                            QueryExpression queryExpression)
        {
            QueryExpression schemaQuery = (QueryExpression)(queryExpression.Clone());

            schemaQuery.Top      = 1;
            schemaQuery.Distinct = false;

            GlazeCommand schemaCmd = (GlazeCommand)(cnn.CreateCommand());

            schemaCmd.Statement = new SelectStatement(schemaQuery);
            return(schemaCmd);
        }
Example #5
0
        void CheckStatement(GlazeFactory glazeFactory, DbConnection connection)
        {
            QueryExpression queryExpression = new QueryExpression();

            queryExpression.SelectItems = new AliasedItem(
                new Expression(new IntegerValue(1),
                               ExpressionOperator.Minus,
                               new IntegerValue(2)));

            GlazeCommand command = (GlazeCommand)(connection.CreateCommand());

            command.Statement = new SelectStatement(queryExpression);

            object c = command.ExecuteScalar();

            Assert.IsNotNull(c);
            int d = Convert.ToInt32(c);

            Assert.AreEqual(-1, d);

            InsertStatement insertStatement = new InsertStatement();

            insertStatement.Table       = new DbObject(new Identifier("no_table"));
            insertStatement.ColumnNames = new AliasedItem(
                new Identifier("test_column"));

            Expression expr = new Expression();

            expr.Left = new IntegerValue(42);
            insertStatement.ColumnValues = new ExpressionItem(expr);
            command.Statement            = insertStatement;

            bool changed = false;

            try
            {
                command.ExecuteNonQuery();
            }
            catch
            {
                changed = true;
            }

            Assert.IsTrue(changed);

            string text = command.CommandText;

            Assert.IsTrue(text.StartsWith("INSERT"));
        }
Example #6
0
        void CheckBindByName(GlazeFactory glazeFactory, DbConnection connection)
        {
            if (glazeFactory == null)
            {
                throw new ArgumentNullException("glazeFactory");
            }

            if (connection == null)
            {
                throw new ArgumentNullException("connection");
            }

            DbCommand command = glazeFactory.CreateCommand();

            Assert.IsNotNull(command);
            GlazeCommand glazeCommand = (GlazeCommand)command;

            Assert.IsFalse(glazeCommand.BindByName);

            glazeCommand.BindByName = true;
            Assert.IsTrue(glazeCommand.BindByName);
        }