コード例 #1
0
 public void SortExpression_WithOneColumn_ReturnsTheSampleEnumerableBackwards()
 {
     var query = QueryTestHelper.FormTestData((x, i) => x.IntProp = i, 10);
     var back = QueryTestHelper.FormTestData((x, i) => x.IntProp = i, 10).Reverse();
     var sortexpr = new SortExpression<TestClass>(new string[] { "IntProp" }, true);
     Assert.Equal(back.ToList()[0].IntProp, sortexpr.Map(query).ToList()[0].IntProp);
 }
コード例 #2
0
 public void SortExpression_WithNullColumns_ReturnsSameNumberElemsAsQuery()
 {
     int number = 100;
     var query = QueryTestHelper.FormTestData((x, i) => x.IntProp = i, number);
     var sortexpr = new SortExpression<TestClass>(t => t.StringProp);
     Assert.Equal(number, sortexpr.Map(query).Count());
 }
コード例 #3
0
        public void SortExpression_WithTwoColumnsAscendingSort_ReturnsSameEnumerable()
        {
            var random = new Random();
            var query = QueryTestHelper.FormTestData((x, i) =>
                {
                    x.IntProp = random.Next(i);
                    x.CharProp = (char)random.Next((int)char.MinValue, (int)char.MaxValue);
                }, 10);
            var sorted = new List<TestClass>(query.ToArray()).OrderBy(x => x.IntProp).ThenBy(x => x.CharProp).ToList();
            var sortexpr = new SortExpression<TestClass>(new string[] { "IntProp", "CharProp" });

            var output = sortexpr.Map(query).ToList();

            Assert.Equal(sorted[0].IntProp, output[0].IntProp);
            Assert.Equal(sorted[0].CharProp, output[0].CharProp);
        }