Пример #1
0
        public virtual IDbCommand GetCommand()
        {
            var conn = new ConnectionFactory().Get(GetConnectionString());
            var cmd = conn.CreateCommand();
            cmd.CommandText = GetQuery();

            return cmd;
        }
Пример #2
0
        public void Get_ConnectionStringSqlClientNativeProvider_OleDbConnection()
        {
            //Call the method to test
            var connStr = "Provider=SQLNCLI10.1;Data Source=ds;Initial Catalog=ic;Integrated Security=SSPI;";
            var actual = new ConnectionFactory().Get(connStr);

            //Assertion
            Assert.That(actual, Is.InstanceOf<OleDbConnection>());
            Assert.That(actual.ConnectionString, Is.EqualTo(connStr));
        }
Пример #3
0
        public void Get_ConnectionStringMsOlapProvider_AdomdConnection()
        {
            //Call the method to test
            var connStr = "Provider=MSOLAP;Data Source=ds;Initial Catalog=ic";
            var actual = new ConnectionFactory().Get(connStr);

            //Assertion
            Assert.That(actual, Is.InstanceOf<AdomdConnection>());
            Assert.That(actual.ConnectionString, Is.EqualTo(connStr));
        }
Пример #4
0
        public void Get_Odbc_OdbcConnection()
        {
            //Call the method to test
            var connStr = "Driver={SQL Server Native Client 10.0};Server=myServerAddress;Database=myDataBase;Uid=myUsername;Pwd=myPassword;";
            var actual = new ConnectionFactory().Get(connStr);

            //Assertion
            Assert.That(actual, Is.InstanceOf<OdbcConnection>());
            Assert.That(actual.ConnectionString, Is.EqualTo(connStr));
        }
Пример #5
0
        public void Get_OleDb_OledbConnection()
        {
            //Call the method to test
            var connStr = "Provider=OledB;Data Source=ds;Initial Catalog=ic";
            var actual = new ConnectionFactory().Get(connStr);

            //Assertion
            Assert.That(actual, Is.InstanceOf<OleDbConnection>());
            Assert.That(actual.ConnectionString, Is.EqualTo(connStr));
        }
Пример #6
0
        public void Get_Adomd_SqlConnection()
        {
            var connStr = "Data Source=ds;Initial Catalog=ic";

            //Call the method to test
            var actual = new ConnectionFactory().Get("Adomd", connStr);

            //Assertion
            Assert.That(actual, Is.InstanceOf<AdomdConnection>());
            Assert.That(actual.ConnectionString, Is.EqualTo(connStr));
        }
Пример #7
0
        public virtual IDbCommand GetCommand()
        {
            if (Query==null)
                return null;

            var conn = new ConnectionFactory().Get(Query.GetConnectionString());
            var cmd = conn.CreateCommand();
            cmd.CommandText = Query.GetQuery();

            return cmd;
        }
Пример #8
0
        public void Get_OleDbExcel_OleDbConnection()
        {
            //Call the method to test
            var connStr = "Provider=Microsoft.ACE.OLEDB.12.0;Data Source=c:\\myFolder\\myExcel2007file.xlsx;Extended Properties=\"Excel 12.0 Xml;HDR=YES\";";
            var providers = new Dictionary<string, string>();
            providers.Add("Microsoft.ACE.OLEDB.12.0", "System.Data.OleDb");
            var factory = new ConnectionFactory(providers);
            var actual = factory.Get(connStr);

            //Assertion
            Assert.That(actual, Is.InstanceOf<OleDbConnection>());
            Assert.That(actual.ConnectionString, Is.EqualTo(connStr));
        }
Пример #9
0
        public void Get_SqlNCli11Dot1_OleDbConnection()
        {
            //Call the method to test
            var connStr = "Provider=SQLNCLI11.1;Data Source=.;Initial Catalog=AdventureWorks2014;Integrated Security=SSPI";
            var actual = new ConnectionFactory().Get(connStr);

            //Assertion
            Assert.That(actual, Is.InstanceOf<OleDbConnection>());
            Assert.That(actual.ConnectionString, Is.EqualTo(connStr));
        }