Пример #1
0
        public void Test_BothNull() {
            //不可空
            IntSegmentCriteria<Customer, int> criteria = new IntSegmentCriteria<Customer, int>( t => t.Tel, null, null );
            Assert.IsNull( criteria.GetPredicate(), criteria.GetPredicate().ToStr() );

            //可空
            IntSegmentCriteria<Customer, int?> criteria2 = new IntSegmentCriteria<Customer, int?>( t => t.Age, null, null );
            Assert.IsNull( criteria2.GetPredicate(), criteria2.GetPredicate().ToStr() );
        }
Пример #2
0
        public void Test_MaxIsNull() {
            //不可空
            IntSegmentCriteria<Customer, int> criteria = new IntSegmentCriteria<Customer, int>( t => t.Tel, 1, null );
            Assert.AreEqual( "t => (t.Tel >= 1)", criteria.GetPredicate().ToString() );

            //可空
            IntSegmentCriteria<Customer, int?> criteria2 = new IntSegmentCriteria<Customer, int?>( t => t.Age, 1, null );
            Assert.AreEqual( "t => (t.Age >= 1)", criteria2.GetPredicate().ToString() );
        }
Пример #3
0
        public void Test_MinGreaterMax() {
            //不可空
            IntSegmentCriteria<Customer, int> criteria = new IntSegmentCriteria<Customer, int>( t => t.Tel, 10, 1 );
            Assert.AreEqual( "t => ((t.Tel >= 1) AndAlso (t.Tel <= 10))", criteria.GetPredicate().ToString() );

            //可空
            IntSegmentCriteria<Customer, int?> criteria2 = new IntSegmentCriteria<Customer, int?>( t => t.Age, 10, 1 );
            Assert.AreEqual( "t => ((t.Age >= 1) AndAlso (t.Age <= 10))", criteria2.GetPredicate().ToString() );
        }
Пример #4
0
        public void Test_BothNull()
        {
            IntSegmentCriteria <AggregateRootSample, int> criteria = new IntSegmentCriteria <AggregateRootSample, int>(t => t.Tel, null, null);

            Assert.Null(criteria.GetPredicate());

            IntSegmentCriteria <AggregateRootSample, int?> criteria2 = new IntSegmentCriteria <AggregateRootSample, int?>(t => t.Age, null, null);

            Assert.Null(criteria2.GetPredicate());
        }
Пример #5
0
        public void TestGetPredicate_MaxIsNull()
        {
            IntSegmentCriteria <AggregateRootSample, int> criteria = new IntSegmentCriteria <AggregateRootSample, int>(t => t.Tel, 1, null);

            Assert.Equal("t => (t.Tel >= 1)", criteria.GetPredicate().ToString());

            IntSegmentCriteria <AggregateRootSample, int?> criteria2 = new IntSegmentCriteria <AggregateRootSample, int?>(t => t.Age, 1, null);

            Assert.Equal("t => (t.Age >= 1)", criteria2.GetPredicate().ToString());
        }
Пример #6
0
        public void TestGetPredicate_MinGreaterMax()
        {
            IntSegmentCriteria <AggregateRootSample, int> criteria = new IntSegmentCriteria <AggregateRootSample, int>(t => t.Tel, 10, 1);

            Assert.Equal("t => ((t.Tel >= 1) AndAlso (t.Tel <= 10))", criteria.GetPredicate().ToString());

            IntSegmentCriteria <AggregateRootSample, int?> criteria2 = new IntSegmentCriteria <AggregateRootSample, int?>(t => t.Age, 10, 1);

            Assert.Equal("t => ((t.Age >= 1) AndAlso (t.Age <= 10))", criteria2.GetPredicate().ToString());
        }
Пример #7
0
        public void TestGetPredicate_MinIsNull()
        {
            IntSegmentCriteria <SampleAggregateRoot, int> criteria = new IntSegmentCriteria <SampleAggregateRoot, int>(t => t.Tel, null, 10);

            Assert.Equal("t => (t.Tel <= 10)", criteria.GetPredicate().ToString());

            IntSegmentCriteria <SampleAggregateRoot, int?> criteria2 = new IntSegmentCriteria <SampleAggregateRoot, int?>(t => t.Age, null, 10);

            Assert.Equal("t => (t.Age <= 10)", criteria2.GetPredicate().ToString());
        }
Пример #8
0
        public void Test_BothNull()
        {
            //不可空
            IntSegmentCriteria <Customer, int> criteria = new IntSegmentCriteria <Customer, int>(t => t.Tel, null, null);

            Assert.IsNull(criteria.GetPredicate(), criteria.GetPredicate().ToStr());

            //可空
            IntSegmentCriteria <Customer, int?> criteria2 = new IntSegmentCriteria <Customer, int?>(t => t.Age, null, null);

            Assert.IsNull(criteria2.GetPredicate(), criteria2.GetPredicate().ToStr());
        }
Пример #9
0
        public void Test_MaxIsNull()
        {
            //不可空
            IntSegmentCriteria <Customer, int> criteria = new IntSegmentCriteria <Customer, int>(t => t.Tel, 1, null);

            Assert.AreEqual("t => (t.Tel >= 1)", criteria.GetPredicate().ToString());

            //可空
            IntSegmentCriteria <Customer, int?> criteria2 = new IntSegmentCriteria <Customer, int?>(t => t.Age, 1, null);

            Assert.AreEqual("t => (t.Age >= 1)", criteria2.GetPredicate().ToString());
        }
Пример #10
0
        public void Test_MinGreaterMax()
        {
            //不可空
            IntSegmentCriteria <Customer, int> criteria = new IntSegmentCriteria <Customer, int>(t => t.Tel, 10, 1);

            Assert.AreEqual("t => ((t.Tel >= 1) AndAlso (t.Tel <= 10))", criteria.GetPredicate().ToString());

            //可空
            IntSegmentCriteria <Customer, int?> criteria2 = new IntSegmentCriteria <Customer, int?>(t => t.Age, 10, 1);

            Assert.AreEqual("t => ((t.Age >= 1) AndAlso (t.Age <= 10))", criteria2.GetPredicate().ToString());
        }
Пример #11
0
        public void TestGetPredicate_Boundary()
        {
            IntSegmentCriteria <SampleAggregateRoot, int> criteria = new IntSegmentCriteria <SampleAggregateRoot, int>(t => t.Tel, 1, 10, Boundary.Neither);

            Assert.Equal("t => ((t.Tel > 1) AndAlso (t.Tel < 10))", criteria.GetPredicate().ToString());

            criteria = new IntSegmentCriteria <SampleAggregateRoot, int>(t => t.Tel, 1, 10, Boundary.Left);
            Assert.Equal("t => ((t.Tel >= 1) AndAlso (t.Tel < 10))", criteria.GetPredicate().ToString());

            IntSegmentCriteria <SampleAggregateRoot, int?> criteria2 = new IntSegmentCriteria <SampleAggregateRoot, int?>(t => t.Age, 1, 10, Boundary.Right);

            Assert.Equal("t => ((t.Age > 1) AndAlso (t.Age <= 10))", criteria2.GetPredicate().ToString());

            criteria2 = new IntSegmentCriteria <SampleAggregateRoot, int?>(t => t.Age, 1, 10, Boundary.Both);
            Assert.Equal("t => ((t.Age >= 1) AndAlso (t.Age <= 10))", criteria2.GetPredicate().ToString());
        }