コード例 #1
0
        public void Parse_DontExecuteEffectivelyQuery()
        {
            var OdbcCount = @"SELECT COUNT(*) from [HumanResources].[Department]";
            var Odbc      = @"DELETE from [HumanResources].[Department]";

            var countBefore = ExecuteCount(OdbcCount);

            if (countBefore == 0) //If nothing was present we cannot assert
            {
                Assert.Inconclusive();
            }

            var cmd = new Queryable.Query(Odbc, ConnectionStringReader.GetOdbcSql());
            var qp  = new ValidationEngineFactory().Instantiate(cmd);

            var res = qp.Parse();

            if (!res.IsSuccesful)//If syntax is incorrect we cannot assert
            {
                Assert.Inconclusive();
            }

            var countAfter = ExecuteCount(OdbcCount);

            Assert.That(countAfter, Is.EqualTo(countBefore));
        }
コード例 #2
0
        public void Parse_CorrectTableName_Success()
        {
            var query = new NBi.Core.Query.Query("SELECT * FROM [HumanResources].[Department];", ConnectionStringReader.GetSqlClient());
            var qp    = new ValidationEngineFactory().Instantiate(query);

            var res = qp.Parse();

            Assert.That(res.IsSuccesful, Is.True);
        }
コード例 #3
0
        public void Parse_CorrectFields_Success()
        {
            var Odbc = "select [DepartmentID], Name from [HumanResources].[Department];";
            var cmd  = new Queryable.Query(Odbc, ConnectionStringReader.GetOdbcSql());
            var qp   = new ValidationEngineFactory().Instantiate(cmd);

            var res = qp.Parse();

            Assert.That(res.IsSuccesful, Is.True);
        }
コード例 #4
0
        public void Parse_CorrectTableName_Success()
        {
            var OleDb = "SELECT * FROM [HumanResources].[Department];";
            var cmd   = new Queryable.Query(OleDb, ConnectionStringReader.GetOleDbSql());
            var qp    = new ValidationEngineFactory().Instantiate(cmd);

            var res = qp.Parse();

            Assert.That(res.IsSuccesful, Is.True);
        }
コード例 #5
0
        public void Parse_WrongSyntax_Failed()
        {
            var Odbc = "SELECTION [DepartmentID], Name, WrongField1, WrongField2 from [HumanResources].[Department];";
            var cmd  = new Queryable.Query(Odbc, ConnectionStringReader.GetOdbcSql());
            var qp   = new ValidationEngineFactory().Instantiate(cmd);

            var res = qp.Parse();

            Assert.That(res.IsSuccesful, Is.False);
            Assert.That(res.Errors, Has.Member("Incorrect syntax near 'SELECTION'."));
        }
コード例 #6
0
        public void Parse_WrongField_Failed()
        {
            var Odbc = "select [DepartmentID], Name, WrongField from [HumanResources].[Department];";
            var cmd  = new Queryable.Query(Odbc, ConnectionStringReader.GetOdbcSql());
            var qp   = new ValidationEngineFactory().Instantiate(cmd);

            var res = qp.Parse();

            Assert.That(res.IsSuccesful, Is.False);
            Assert.That(res.Errors, Has.Member("Invalid column name 'WrongField'."));
        }
コード例 #7
0
        public void Parse_WrongTableName_Failed()
        {
            var Odbc = "SELECT * FROM WrongTableName;";
            var cmd  = new Queryable.Query(Odbc, ConnectionStringReader.GetOdbcSql());
            var qp   = new ValidationEngineFactory().Instantiate(cmd);

            var res = qp.Parse();

            Assert.That(res.IsSuccesful, Is.False);
            Assert.That(res.Errors, Has.Member("Invalid object name 'WrongTableName'."));
        }
コード例 #8
0
        public void Parse_WrongSyntax_Failed()
        {
            var sql = "SELECTION [DepartmentID], Name, WrongField1, WrongField2 from [HumanResources].[Department];";
            var cmd = new NBi.Core.Query.Query(sql, ConnectionStringReader.GetSqlClient());
            var qp  = new ValidationEngineFactory().Instantiate(cmd);

            var res = qp.Parse();

            Assert.That(res.IsSuccesful, Is.False);
            Assert.That(res.Errors[0], Is.EqualTo("Incorrect syntax near 'SELECTION'."));
        }
コード例 #9
0
        public void Parse_WrongField_Failed()
        {
            var sql = "select [DepartmentID], Name, WrongField from [HumanResources].[Department];";
            var cmd = new NBi.Core.Query.Query(sql, ConnectionStringReader.GetSqlClient());
            var qp  = new ValidationEngineFactory().Instantiate(cmd);

            var res = qp.Parse();

            Assert.That(res.IsSuccesful, Is.False);
            Assert.That(res.Errors[0], Is.EqualTo("Invalid column name 'WrongField'."));
        }
コード例 #10
0
        public void Parse_WrongTableName_Failed()
        {
            var sql = "SELECT * FROM WrongTableName;";
            var cmd = new NBi.Core.Query.Query(sql, ConnectionStringReader.GetSqlClient());
            var qp  = new ValidationEngineFactory().Instantiate(cmd);

            var res = qp.Parse();

            Assert.That(res.IsSuccesful, Is.False);
            Assert.That(res.Errors[0], Is.EqualTo("Invalid object name 'WrongTableName'."));
        }