Esempio n. 1
0
        public void Test1()
        {
            // 测试命令参数超过最大值的情况

            FieldInfo field = typeof(SqlInfo).GetField("MaxParameterCount", BindingFlags.Static | BindingFlags.NonPublic);

            field.SetValue(null, 3);

            DbCommand command = CreateDbCommand();

            SqlInfo info = SqlInfo.Create(command);

            Assert.AreEqual(4, info.Parameters.Count);
            Assert.AreEqual("#####", info.Parameters[3].Name);
        }
Esempio n. 2
0
        public void Test2()
        {
            // 测试特殊参数场景

            DbCommand command = CreateDbCommand();

            SqlInfo info = SqlInfo.Create(command);

            Assert.AreEqual(command.CommandText, info.SqlText.ToString());



            SqlInfo info2 = SqlInfo.Create(null);

            Assert.IsNull(info2);


            command.Parameters.Clear();
            SqlInfo info3 = SqlInfo.Create(command);

            Assert.IsNull(info3.Parameters);
        }