⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 whereconditiontest.cs

📁 基于LINQ和.NET 3.5 的数据库源码
💻 CS
字号:
using Lephone.Data;
using Lephone.Data.Builder.Clause;
using Lephone.Data.Common;
using Lephone.Data.Dialect;
using Lephone.Data.SqlEntry;
using NUnit.Framework;

namespace Lephone.UnitTest.Data.Inner
{
    [TestFixture]
    public class WhereConditionTest
    {
        [Test]
        public void Test1()
        {
            WhereCondition c = null;
            c = ((c & null) | null);
            Assert.IsTrue(c is EmptyCondition);
        }

        [Test]
        public void Test2()
        {
            WhereCondition c = null;
            c = ((c & null) | null);
            WhereClause cc = new WhereClause(c);
            DataParamterCollection dpc = new DataParamterCollection();
            Assert.AreEqual("", cc.ToSqlText(dpc, new Access()));
        }

        [Test]
        public void Test3()
        {
            WhereCondition c = WhereCondition.EmptyCondition;
            c = ((c & null) | null);
            WhereClause cc = new WhereClause(c);
            DataParamterCollection dpc = new DataParamterCollection();
            Assert.AreEqual("", cc.ToSqlText(dpc, new Access()));
        }

        [Test]
        public void Test4()
        {
            WhereCondition c = WhereCondition.EmptyCondition;
            c &= (CK.K["Id"] == 1 | CK.K["Age"] > 18);
            WhereClause cc = new WhereClause(c);
            DataParamterCollection dpc = new DataParamterCollection();
            Assert.IsFalse(c is EmptyCondition);
            Assert.AreEqual(" Where ([Id] = @Id_0) Or ([Age] > @Age_1)", cc.ToSqlText(dpc, new Access()));
        }

        [Test]
        public void Test5()
        {
            WhereCondition c = WhereCondition.EmptyCondition;
            c = c.And(CK.K["Id"].Eq(1)).Or(CK.K["Age"].Gt(18));
            WhereClause cc = new WhereClause(c);
            DataParamterCollection dpc = new DataParamterCollection();
            Assert.AreEqual(" Where ([Id] = @Id_0) Or ([Age] > @Age_1)", cc.ToSqlText(dpc, new Access()));
        }

        [Test]
        public void Test6()
        {
            WhereCondition c = null;
            c &= (CK.K["Id"] == 1 | CK.K["Age"] > 18);
            c &= null;
            c |= null;
            c &= CK.K["Gender"] == true;
            WhereClause cc = new WhereClause(c);
            DataParamterCollection dpc = new DataParamterCollection();
            Assert.AreEqual(" Where (([Id] = @Id_0) Or ([Age] > @Age_1)) And ([Gender] = @Gender_2)", cc.ToSqlText(dpc, new Access()));
        }

        [Test]
        public void Test7()
        {
            WhereCondition c = WhereCondition.EmptyCondition;
            c = c.And(CK.K["Id"].Eq(1)).Or(CK.K["Age"].Gt(18));
            c = c.And(null);
            c = c.Or(null);
            c = c.And(CK.K["Gender"].Eq(true));
            WhereClause cc = new WhereClause(c);
            DataParamterCollection dpc = new DataParamterCollection();
            Assert.AreEqual(" Where (([Id] = @Id_0) Or ([Age] > @Age_1)) And ([Gender] = @Gender_2)", cc.ToSqlText(dpc, new Access()));
        }

        [Test]
        public void Test8()
        {
            WhereCondition c = WhereCondition.EmptyCondition;
            c = c.And(CK.K["Id"] == 1).Or(CK.K["Age"] > 18);
            c = c.And(null);
            c = c.Or(null);
            c = c.And(CK.K["Gender"].Eq(true));
            WhereClause cc = new WhereClause(c);
            DataParamterCollection dpc = new DataParamterCollection();
            Assert.AreEqual(" Where (([Id] = @Id_0) Or ([Age] > @Age_1)) And ([Gender] = @Gender_2)", cc.ToSqlText(dpc, new Access()));
        }
    }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -