public void TestOrderBy() { TestHandler.Handle <DummyContext> ((options) => { using (var ctx = new DummyContext(options)) { ctx.Person.AddRange( new Person() { FirstName = "Carlos", LastName = "Sank", Age = 23 }, new Person() { FirstName = "Mario", LastName = "Sank", Age = 40 }, new Person() { FirstName = "Carla", LastName = "Sank", Age = 11 }, new Person() { FirstName = "Juan", LastName = "Gabriel Montandon", Age = 40 } ); ctx.SaveChanges(); var resultForNames = new QueryPaginatorBasic() .GetAsync <Person> (QueryPersonInfo, BuildRequestParameterOrderBy("FirstName", OrderType.ASC)) .Result; var orderByFirstName = resultForNames.Data.Select(x => x.FirstName).ToArray(); var resultForAge = new QueryPaginatorBasic() .GetAsync <Person> (QueryPersonInfo, BuildRequestParameterOrderBy("Age", OrderType.ASC)) .Result; var orderByAge = resultForAge.Data.Select(x => x.Age).ToArray(); QueryTestHelper.LogToFile <TestQueryPaginator>(orderByAge); Assert.AreEqual("Carla", orderByFirstName[0]); Assert.AreEqual("Carlos", orderByFirstName[1]); Assert.AreEqual("Juan", orderByFirstName[2]); Assert.AreEqual("Mario", orderByFirstName[3]); Assert.AreEqual(11, orderByAge[0]); Assert.AreEqual(23, orderByAge[1]); Assert.AreEqual(40, orderByAge[2]); Assert.AreEqual(40, orderByAge[3]); ClearRecords(ctx); } }); }
public TestQueryPaginator() { Logger = QueryTestHelper.GetLogger <TestQueryPaginator> (); TestHandler.Connection = Connection; QueryPersonInfo = new QueryConfig("Person", new QueryField("FirstName"), new QueryField("LastName"), new QueryField(name: "Age", type: typeof(int))); QueryPersonInfo.Provider = DatabaseProvider.SQLite; QueryPersonInfo.ConnectionString = Connection; }