@@ -22,6 +22,8 @@ private class Dummy
2222 public string FirstName { get ; set ; }
2323
2424 public string LastName { get ; set ; }
25+
26+ public DateTime BirthDate { get ; set ; }
2527 }
2628
2729 private IList < Dummy > _fixtures ;
@@ -32,15 +34,15 @@ public void SetupFixtures()
3234 {
3335 _fixtures = new List < Dummy >
3436 {
35- new Dummy { Id = "1" , FirstName = "Thomas" , LastName = "Paine" } ,
36- new Dummy { Id = "2" , FirstName = "Samuel" , LastName = "Adams" } ,
37- new Dummy { Id = "3" , FirstName = "George" , LastName = "Washington" } ,
38- new Dummy { Id = "4" , FirstName = "Thomas" , LastName = "Jefferson" } ,
39- new Dummy { Id = "5" , FirstName = "Martha" , LastName = "Washington" } ,
40- new Dummy { Id = "6" , FirstName = "Abraham" , LastName = "Lincoln" } ,
41- new Dummy { Id = "7" , FirstName = "Andrew" , LastName = "Jackson" } ,
42- new Dummy { Id = "8" , FirstName = "Andrew" , LastName = "Johnson" } ,
43- new Dummy { Id = "9" , FirstName = "William" , LastName = "Harrison" }
37+ new Dummy { Id = "1" , FirstName = "Thomas" , LastName = "Paine" , BirthDate = new DateTime ( 1737 , 2 , 9 ) } ,
38+ new Dummy { Id = "2" , FirstName = "Samuel" , LastName = "Adams" , BirthDate = new DateTime ( 1722 , 9 , 27 ) } ,
39+ new Dummy { Id = "3" , FirstName = "George" , LastName = "Washington" , BirthDate = new DateTime ( 1732 , 2 , 22 ) } ,
40+ new Dummy { Id = "4" , FirstName = "Thomas" , LastName = "Jefferson" , BirthDate = new DateTime ( 1743 , 4 , 13 ) } ,
41+ new Dummy { Id = "5" , FirstName = "Martha" , LastName = "Washington" , BirthDate = new DateTime ( 1731 , 6 , 13 ) } ,
42+ new Dummy { Id = "6" , FirstName = "Abraham" , LastName = "Lincoln" , BirthDate = new DateTime ( 1809 , 2 , 12 ) } ,
43+ new Dummy { Id = "7" , FirstName = "Andrew" , LastName = "Jackson" , BirthDate = new DateTime ( 1767 , 3 , 15 ) } ,
44+ new Dummy { Id = "8" , FirstName = "Andrew" , LastName = "Johnson" , BirthDate = new DateTime ( 1808 , 12 , 29 ) } ,
45+ new Dummy { Id = "9" , FirstName = "William" , LastName = "Harrison" , BirthDate = new DateTime ( 1773 , 2 , 9 ) }
4446 } ;
4547 _fixturesQuery = _fixtures . AsQueryable ( ) ;
4648 }
@@ -52,7 +54,7 @@ private DefaultSortingTransformer GetTransformer()
5254 { "Dummy" , "Dummies" }
5355 } ) ;
5456 var registrar = new ResourceTypeRegistrar ( new DefaultNamingConventions ( pluralizationService ) ) ;
55- var registration = registrar . BuildRegistration ( typeof ( Dummy ) ) ;
57+ var registration = registrar . BuildRegistration ( typeof ( Dummy ) ) ;
5658 var registry = new ResourceTypeRegistry ( ) ;
5759 registry . AddRegistration ( registration ) ;
5860 return new DefaultSortingTransformer ( registry ) ;
@@ -131,13 +133,22 @@ public void Returns_400_if_sort_argument_is_whitespace_descending()
131133 [ TestMethod ]
132134 public void Returns_400_if_no_property_exists ( )
133135 {
134- RunTransformAndExpectFailure ( "http://api.example.com/dummies?sort=foobar" , "The attribute \" foobar\" does not exist on type \" dummies\" ." ) ;
136+ RunTransformAndExpectFailure ( "http://api.example.com/dummies?sort=foobar" ,
137+ "The attribute \" foobar\" does not exist on type \" dummies\" ." ) ;
135138 }
136139
137140 [ TestMethod ]
138141 public void Returns_400_if_the_same_property_is_specified_more_than_once ( )
139142 {
140- RunTransformAndExpectFailure ( "http://api.example.com/dummies?sort=last-name,last-name" , "The attribute \" last-name\" was specified more than once." ) ;
143+ RunTransformAndExpectFailure ( "http://api.example.com/dummies?sort=last-name,last-name" ,
144+ "The attribute \" last-name\" was specified more than once." ) ;
145+ }
146+
147+ [ TestMethod ]
148+ public void Can_sort_by_DateTimeOffset ( )
149+ {
150+ var array = GetArray ( "http://api.example.com/dummies?sort=birth-date" ) ;
151+ array . Should ( ) . BeInAscendingOrder ( d => d . BirthDate ) ;
141152 }
142153 }
143154}
0 commit comments