public void Test_GetPredicate_Boundary()
        {
            var result = new StringBuilder();

            result.Append("t => ((t.DateValue > Convert(Parse(\"2000/1/1 0:00:00\"), DateTime))");
            result.Append(" AndAlso (t.DateValue < Convert(Parse(\"2000/1/3 0:00:00\"), DateTime)))");
            var criteria = new DateSegmentCriteria <AggregateRootSample, DateTime>(t => t.DateValue, _min, _max, Boundary.Neither);

            Assert.Equal(result.ToString(), criteria.GetPredicate().ToString());

            result = new StringBuilder();
            result.Append("t => ((t.DateValue >= Convert(Parse(\"2000/1/1 0:00:00\"), DateTime))");
            result.Append(" AndAlso (t.DateValue < Convert(Parse(\"2000/1/3 0:00:00\"), DateTime)))");
            criteria = new DateSegmentCriteria <AggregateRootSample, DateTime>(t => t.DateValue, _min, _max, Boundary.Left);
            Assert.Equal(result.ToString(), criteria.GetPredicate().ToString());

            result = new StringBuilder();
            result.Append("t => ((t.NullableDateValue > Convert(Parse(\"2000/1/1 0:00:00\"), Nullable`1))");
            result.Append(" AndAlso (t.NullableDateValue <= Convert(Parse(\"2000/1/3 0:00:00\"), Nullable`1)))");
            var criteria2 = new DateSegmentCriteria <AggregateRootSample, DateTime?>(t => t.NullableDateValue, _min, _max, Boundary.Right);

            Assert.Equal(result.ToString(), criteria2.GetPredicate().ToString());

            result = new StringBuilder();
            result.Append("t => ((t.NullableDateValue >= Convert(Parse(\"2000/1/1 0:00:00\"), Nullable`1))");
            result.Append(" AndAlso (t.NullableDateValue <= Convert(Parse(\"2000/1/3 0:00:00\"), Nullable`1)))");
            criteria2 = new DateSegmentCriteria <AggregateRootSample, DateTime?>(t => t.NullableDateValue, _min, _max, Boundary.Both);
            Assert.Equal(result.ToString(), criteria2.GetPredicate().ToString());
        }
Ejemplo n.º 2
0
        public void TestGetPredicate_Boundary()
        {
            var result = new StringBuilder();

            result.AppendFormat("t => ((t.DateValue > {0})", DateTime.Parse("2000/1/1 0:00:00"));
            result.AppendFormat(" AndAlso (t.DateValue < {0}))", DateTime.Parse("2000/1/3 0:00:00"));
            var criteria = new DateSegmentCriteria <AggregateRootSample, DateTime>(t => t.DateValue, _min, _max, Boundary.Neither);

            Assert.Equal(result.ToString(), criteria.GetPredicate().ToString());

            result = new StringBuilder();
            result.AppendFormat("t => ((t.DateValue >= {0})", DateTime.Parse("2000/1/1 0:00:00"));
            result.AppendFormat(" AndAlso (t.DateValue < {0}))", DateTime.Parse("2000/1/3 0:00:00"));
            criteria = new DateSegmentCriteria <AggregateRootSample, DateTime>(t => t.DateValue, _min, _max, Boundary.Left);
            Assert.Equal(result.ToString(), criteria.GetPredicate().ToString());

            result = new StringBuilder();
            result.AppendFormat("t => ((t.NullableDateValue > {0})", DateTime.Parse("2000/1/1 0:00:00"));
            result.AppendFormat(" AndAlso (t.NullableDateValue <= {0}))", DateTime.Parse("2000/1/3 0:00:00"));
            var criteria2 = new DateSegmentCriteria <AggregateRootSample, DateTime?>(t => t.NullableDateValue, _min, _max, Boundary.Right);

            Assert.Equal(result.ToString(), criteria2.GetPredicate().ToString());

            result = new StringBuilder();
            result.AppendFormat("t => ((t.NullableDateValue >= {0})", DateTime.Parse("2000/1/1 0:00:00"));
            result.AppendFormat(" AndAlso (t.NullableDateValue <= {0}))", DateTime.Parse("2000/1/3 0:00:00"));
            criteria2 = new DateSegmentCriteria <AggregateRootSample, DateTime?>(t => t.NullableDateValue, _min, _max, Boundary.Both);
            Assert.Equal(result.ToString(), criteria2.GetPredicate().ToString());
        }
Ejemplo n.º 3
0
        public void Test_Min_Max() {
            //不可空
            DateSegmentCriteria<Customer, DateTime> criteria = new DateSegmentCriteria<Customer, DateTime>( t => t.Birthday, _min, _max );
            Assert.AreEqual( "t => ((t.Birthday >= 2000/1/1 0:00:00) AndAlso (t.Birthday < 2000/1/3 0:00:00))", criteria.GetPredicate().ToString() );

            //可空
            DateSegmentCriteria<Customer, DateTime?> criteria2 = new DateSegmentCriteria<Customer, DateTime?>( t => t.NullableBirthday, _min, _max );
            Assert.AreEqual( "t => ((t.NullableBirthday >= 2000/1/1 0:00:00) AndAlso (t.NullableBirthday < 2000/1/3 0:00:00))", criteria2.GetPredicate().ToString() );
        }
        public void Test_Min_Max()
        {
            //不可空
            DateSegmentCriteria <Customer, DateTime> criteria = new DateSegmentCriteria <Customer, DateTime>(t => t.Birthday, _min, _max);

            Assert.AreEqual("t => ((t.Birthday >= 2000/1/1 0:00:00) AndAlso (t.Birthday < 2000/1/3 0:00:00))", criteria.GetPredicate().ToString());

            //可空
            DateSegmentCriteria <Customer, DateTime?> criteria2 = new DateSegmentCriteria <Customer, DateTime?>(t => t.NullableBirthday, _min, _max);

            Assert.AreEqual("t => ((t.NullableBirthday >= 2000/1/1 0:00:00) AndAlso (t.NullableBirthday < 2000/1/3 0:00:00))", criteria2.GetPredicate().ToString());
        }
        public void Test_GetPredicate()
        {
            var result = new StringBuilder();

            result.Append("t => ((t.DateValue >= Convert(Parse(\"2000/1/1 0:00:00\"), DateTime))");
            result.Append(" AndAlso (t.DateValue < Convert(Parse(\"2000/1/3 0:00:00\"), DateTime)))");
            var criteria = new DateSegmentCriteria <AggregateRootSample, DateTime>(t => t.DateValue, _min, _max);

            _output.WriteLine(criteria.GetPredicate().ToString());
            Assert.Equal(result.ToString(), criteria.GetPredicate().ToString());

            result = new StringBuilder();
            result.Append("t => ((t.NullableDateValue >= Convert(Parse(\"2000/1/1 0:00:00\"), Nullable`1))");
            result.Append(" AndAlso (t.NullableDateValue < Convert(Parse(\"2000/1/3 0:00:00\"), Nullable`1)))");
            var criteria2 = new DateSegmentCriteria <AggregateRootSample, DateTime?>(t => t.NullableDateValue, _min, _max);

            _output.WriteLine(criteria2.GetPredicate().ToString());
            Assert.Equal(result.ToString(), criteria2.GetPredicate().ToString());
        }