コード例 #1
0
        static void Main(string[] args)
        {
            //Test of open and close of SQL Connection Class

            var sqlConn = new SQLConnection("abc");
            sqlConn.OpenDBConnection();
            sqlConn.CloseDBConnection();

            // Test of open and close of Oracle Connection Class

            var oracleConn = new OracleConnection("123");

            oracleConn.OpenDBConnection();
            oracleConn.CloseDBConnection();

            //test of empty string passed for connection string - should throw an exception
            // comment out test to proceed with rest of test cases.
             //   var sqlConn2 = new SQLConnection("");

            //test of null string passed for connection string - should throw an exception
            // comment out test to proceed with rest of test cases.

             //   var oracleConn2 = new OracleConnection(null);

            //test to ensure can't open an already open connection - should throw an exception
            // comment out test to proceed with rest of test cases.
            //    sqlConn.OpenDBConnection();
            //    sqlConn.OpenDBConnection();

            //test to ensure cant close an already closed connection - should throw an exception

            oracleConn.CloseDBConnection();
        }
コード例 #2
0
        static void Main(string[] args)
        {
            //Polymorphism Example
            var dbConn = new SQLConnection("abcdefgh");

            var dbCmd = new DBCommand(dbConn,"select * from tbl;");

            dbCmd.Execute();

            var dbConn2 = new OracleConnection("12345");

            var dbCmd2 = new DBCommand(dbConn2,"Select name, count(*) from tbl;");

            dbCmd2.Execute();
        }