Пример #1
0
        public void TestEnds()
        {
            Expression <Func <Sample, bool> > expected = t => t.StringValue.EndsWith("A");

            Assert.Equal(expected.ToString(), Lambda.Ends <Sample>("StringValue", "A").ToString());

            Expression <Func <Sample, bool> > expected2 = t => t.Test2.StringValue.EndsWith("A");

            Assert.Equal(expected2.ToString(), Lambda.Ends <Sample>("Test2.StringValue", "A").ToString());

            Expression <Func <Sample, bool> > expected3 = t => t.Test2.Test3.StringValue.EndsWith("A");

            Assert.Equal(expected3.ToString(), Lambda.Ends <Sample>("Test2.Test3.StringValue", "A").ToString());
        }
Пример #2
0
        public void TestEnds()
        {
            //一级属性
            Expression <Func <Test1, bool> > expected = t => t.Name.EndsWith("A");

            Assert.AreEqual(expected.ToString(), Lambda.Ends <Test1>("Name", "A").ToString());

            //二级属性
            Expression <Func <Test1, bool> > expected2 = t => t.A.Address.EndsWith("A");

            Assert.AreEqual(expected2.ToString(), Lambda.Ends <Test1>("A.Address", "A").ToString());

            //三级属性
            Expression <Func <Test1, bool> > expected3 = t => t.A.B.Name.EndsWith("A");

            Assert.AreEqual(expected3.ToString(), Lambda.Ends <Test1>("A.B.Name", "A").ToString());
        }