Exemple #1
0
        public void SqlQueryable_OrderBy()
        {
            // Prepare the test data
            IQueryable <Record> query = new SqliteQueryable(connection, "Course", new[] { "Id", "Name" });

            // Perform the test operation
            Dictionary <string, object>[] result = query
                                                   .OrderBy(x => x["Course"]["Id"])
                                                   .Flatten()
                                                   .ToArray();

            // Check the test result
            Assert.AreEqual(ConnectionTestHelper.CountCourses, result.Length);
            long last = 0;

            foreach (Dictionary <string, object> record in result)
            {
                Assert.IsTrue((long)record["Id"] > last);
                last = (long)record["Id"];
            }
        }
Exemple #2
0
        public void SqlQueryable_ThenByDescending()
        {
            // Prepare the test data
            IQueryable <Record> query = new SqliteQueryable(connection, "SortTest", new[] { "Id", "Alpha", "Beta" });

            // Perform the test operation
            Dictionary <string, object>[] result = query
                                                   .OrderBy(x => x["SortTest"]["Alpha"])
                                                   .ThenByDescending(x => x["SortTest"]["Beta"])
                                                   .Flatten()
                                                   .ToArray();

            // Check the test result
            Assert.AreEqual(ConnectionTestHelper.CountSortTestAlphas * ConnectionTestHelper.CountSortTestBetas, result.Length);
            Dictionary <string, object> last = result[0];

            for (int i = 1; i < result.Length; i++)
            {
                Dictionary <string, object> record = result[i];
                Assert.IsTrue((long)record["Alpha"] > (long)last["Alpha"] || (long)record["Beta"] < (long)last["Beta"]);
                last = record;
            }
        }