public void TestGetPredicate_Boundary() { var result = new StringBuilder(); result.AppendFormat("t => ((t.DateValue > {0})", DateTime.Parse("2000/1/1 10:10:10")); result.AppendFormat(" AndAlso (t.DateValue < {0}))", DateTime.Parse("2000/1/2 10:10:10")); var criteria = new DateTimeSegmentCriteria <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 10:10:10")); result.AppendFormat(" AndAlso (t.DateValue < {0}))", DateTime.Parse("2000/1/2 10:10:10")); criteria = new DateTimeSegmentCriteria <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 10:10:10")); result.AppendFormat(" AndAlso (t.NullableDateValue <= {0}))", DateTime.Parse("2000/1/2 10:10:10")); var criteria2 = new DateTimeSegmentCriteria <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 10:10:10")); result.AppendFormat(" AndAlso (t.NullableDateValue <= {0}))", DateTime.Parse("2000/1/2 10:10:10")); criteria2 = new DateTimeSegmentCriteria <AggregateRootSample, DateTime?>(t => t.NullableDateValue, _min, _max, Boundary.Both); Assert.Equal(result.ToString(), criteria2.GetPredicate().ToString()); }
public void TestGetPredicate_Boundary() { var result = new StringBuilder(); result.Append("t => ((t.DateValue > Convert(Parse(\"2000/1/1 10:10:10\"), DateTime))"); result.Append(" AndAlso (t.DateValue < Convert(Parse(\"2000/1/2 10:10:10\"), DateTime)))"); var criteria = new DateTimeSegmentCriteria <SampleAggregateRoot, 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 10:10:10\"), DateTime))"); result.Append(" AndAlso (t.DateValue < Convert(Parse(\"2000/1/2 10:10:10\"), DateTime)))"); criteria = new DateTimeSegmentCriteria <SampleAggregateRoot, 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 10:10:10\"), Nullable`1))"); result.Append(" AndAlso (t.NullableDateValue <= Convert(Parse(\"2000/1/2 10:10:10\"), Nullable`1)))"); var criteria2 = new DateTimeSegmentCriteria <SampleAggregateRoot, 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 10:10:10\"), Nullable`1))"); result.Append(" AndAlso (t.NullableDateValue <= Convert(Parse(\"2000/1/2 10:10:10\"), Nullable`1)))"); criteria2 = new DateTimeSegmentCriteria <SampleAggregateRoot, DateTime?>(t => t.NullableDateValue, _min, _max, Boundary.Both); Assert.Equal(result.ToString(), criteria2.GetPredicate().ToString()); }
public void Test_Min_Max() { //不可空 DateTimeSegmentCriteria<Customer, DateTime> criteria = new DateTimeSegmentCriteria<Customer, DateTime>( t => t.Birthday, _min, _max ); Assert.AreEqual( "t => ((t.Birthday >= 2000/1/1 10:10:10) AndAlso (t.Birthday <= 2000/1/2 10:10:10))", criteria.GetPredicate().ToString() ); //可空 DateTimeSegmentCriteria<Customer, DateTime?> criteria2 = new DateTimeSegmentCriteria<Customer, DateTime?>( t => t.NullableBirthday, _min, _max ); Assert.AreEqual( "t => ((t.NullableBirthday >= 2000/1/1 10:10:10) AndAlso (t.NullableBirthday <= 2000/1/2 10:10:10))", criteria2.GetPredicate().ToString() ); }
public void Test_Min_Max() { //不可空 DateTimeSegmentCriteria <Customer, DateTime> criteria = new DateTimeSegmentCriteria <Customer, DateTime>(t => t.Birthday, _min, _max); Assert.AreEqual("t => ((t.Birthday >= 2000/1/1 10:10:10) AndAlso (t.Birthday <= 2000/1/2 10:10:10))", criteria.GetPredicate().ToString()); //可空 DateTimeSegmentCriteria <Customer, DateTime?> criteria2 = new DateTimeSegmentCriteria <Customer, DateTime?>(t => t.NullableBirthday, _min, _max); Assert.AreEqual("t => ((t.NullableBirthday >= 2000/1/1 10:10:10) AndAlso (t.NullableBirthday <= 2000/1/2 10:10:10))", criteria2.GetPredicate().ToString()); }
public void Test_GetPredicate() { var result = new StringBuilder(); result.Append("t => ((t.DateValue >= Convert(Parse(\"2000/1/1 10:10:10\"), DateTime))"); result.Append(" AndAlso (t.DateValue <= Convert(Parse(\"2000/1/2 10:10:10\"), DateTime)))"); var criteria = new DateTimeSegmentCriteria <AggregateRootSample, DateTime>(t => t.DateValue, _min, _max); Assert.Equal(result.ToString(), criteria.GetPredicate().ToString()); result = new StringBuilder(); result.Append("t => ((t.NullableDateValue >= Convert(Parse(\"2000/1/1 10:10:10\"), Nullable`1))"); result.Append(" AndAlso (t.NullableDateValue <= Convert(Parse(\"2000/1/2 10:10:10\"), Nullable`1)))"); var criteria2 = new DateTimeSegmentCriteria <AggregateRootSample, DateTime?>(t => t.NullableDateValue, _min, _max); Assert.Equal(result.ToString(), criteria2.GetPredicate().ToString()); }