示例#1
0
        public void CanCreateValidQueryOnAnyDatabaseCall(SqlCommandType calltype, DatabaseEngineType dbtype, string result)
        {
            var q = new UniSqlQuery(
                "x", "y", new { a = "~x", b = "~", c = 23, d = "u" }, calltype
                );

            Assert.AreEqual(result, q.PrepareQueryText(dbtype));
        }
示例#2
0
        public void CanSupplyValidParameters()
        {
            var q = new UniSqlQuery(
                "x", "y", new { a = "~x", b = "~", c = 23, d = "u" }, SqlCommandType.Call
                );

            var con = new SqlConnection();

            var cmd = q.PrepareCommand(con, new { x = 1 });

            Assert.AreEqual(cmd.CommandText, q.PrepareQueryText(DatabaseEngineType.SqlServer));

            Assert.AreEqual(2, cmd.Parameters.Count);
            Assert.AreEqual(1, ((IDbDataParameter)cmd.Parameters["x"]).Value);
            Assert.AreEqual(DBNull.Value, ((IDbDataParameter)cmd.Parameters["b"]).Value);
        }