Ejemplo n.º 1
0
        public void Clone_Test()
        {
            using (CUBRIDConnection conn = new CUBRIDConnection())
            {
                LogTestStep("Clone a connection");
                conn.ConnectionString = DBHelper.connString;
                Log("change a property value of the original connection");
                conn.SetConnectionTimeout(45);
                conn.Open();

                Log("call the Clone method");
                CUBRIDConnection clonedConn = conn.Clone();
                Assert.IsTrue(clonedConn != null);

                Log("The property values are different between the original connection and the cloned connection");
                Assert.AreEqual(45, conn.ConnectionTimeout);
                Assert.AreEqual(30, clonedConn.ConnectionTimeout);

                try
                {
                    clonedConn.Open();

                    Log("Close the original connection, check the cloned connection works well");
                    conn.Close();
                    Assert.IsTrue(DBHelper.GetTableRowsCount("db_class", clonedConn) > 0);
                    clonedConn.Close();
                    LogStepPass();
                }
                catch (Exception ex)
                {
                    Log(ex.Message);
                    LogStepFail();
                }
                finally
                {
                    LogTestResult();
                    conn.Close();
                    clonedConn.Close();
                }
            }
        }
Ejemplo n.º 2
0
        public void APIS_492()
        {
            int timeout = 0;

            using (CUBRIDConnection conn = new CUBRIDConnection())
            {
                LogTestStep("Invalid timeout value");
                try
                {
                    timeout = 100;
                    conn.SetConnectionTimeout(timeout);
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    Assert.AreEqual("Invalid Timeout value! Expected a value between 1 and 99!", ex.Message);
                    LogStepPass();
                }

                LogTestStep("Valid timeout value, valid connection, set before open, check the timeout value is set successfuly");
                timeout = 3;
                conn.SetConnectionTimeout(timeout);
                

                //The database in the connection string does not exist
                conn.ConnectionString = "server=test-db-server;database=demodb;port=33000;user=public;password="******"The connection should not be opened");
                    LogStepFail();
                }
                catch (Exception ex)
                {
                    Console.WriteLine(ex.Message);
                    stopwatch.Stop();
                    elapseTime = (int)stopwatch.ElapsedMilliseconds / 1000;
                    int diffTime = elapseTime - timeout;
                    Log(ex.Message);
                    Assert.AreEqual(timeout, conn.ConnectionTimeout);
                    if (diffTime >= 0 && diffTime < 10)
                    {
                        LogStepPass();
                    }
                    else
                    {
                        LogStepFail();
                    }
                }

                LogTestStep("Valid timout value, valid connection, set after open");
                try
                {
                    timeout = 20;
                    conn.SetConnectionTimeout(timeout);
                    Log("Not allowed to change the 'ConnectionTimeout' property while the connection state is!: Open.");
                    LogStepFail();
                }
                catch (Exception ex)
                {
                    Assert.AreEqual("Not allowed to change the 'ConnectionTimeout' property while the connection state is!: Open.", ex.Message);
                    LogStepPass();
                }

                LogTestResult();

            }
        }
Ejemplo n.º 3
0
    private static void Test_SetConnectionTimeout()
    {
        try
        {
            CUBRIDConnection conn = new CUBRIDConnection();
            conn.SetConnectionTimeout(30);
        }
        catch (Exception e)
        {
            Debug.Assert(e.Message == "The connection is not open!");
        }

        try
        {
            CUBRIDConnection conn = new CUBRIDConnection();
            conn.ConnectionString = connString;
            conn.Open();
            conn.SetConnectionTimeout(30);
            conn.Close();
        }
        catch (Exception e)
        {
            Console.WriteLine(e.ToString());
        }
    }