コード例 #1
0
        internal void ParsesCorrectly(string query, string[] properties, SortDirection[] directions)
        {
            var context  = new SortContext(GetQuery(query));
            var expected = properties.Zip(directions, (s, d) => new
            {
                Name      = s,
                Direction = d
            }).ToList();
            var actual = context.Properties.Select(p => new
            {
                p.Name,
                p.Direction
            }).ToList();

            Assert.Equal(expected, actual);
        }
コード例 #2
0
        public void SortArray_AscendingSortByMin_ReturnsOutputArray()
        {
            var sortContext = new SortContext();

            sortContext.SetSortStrategy(new AscendingSortByMin());

            int[,] expectedArray =
            {
                {  4, 19, -5 },
                {  7,  1,  0 },
                {  9,  6,  2 },
                { 16,  5, 13 }
            };

            int[,] outputArray = sortContext.ExecuteSort(inputArray);

            CollectionAssert.AreEqual(expectedArray, outputArray);
        }
コード例 #3
0
ファイル: Query.cs プロジェクト: sergey-litvinov-work/saule
        public static object ApplySorting(object data, SortContext context, ApiResource resource)
        {
            var queryable = data as IQueryable;

            if (queryable != null)
            {
                return(new SortInterpreter(context, resource).Apply(queryable));
            }

            var enumerable = data as IEnumerable;

            if (enumerable != null)
            {
                // all queryables are enumerable, so this needs to be after
                // the queryable case
                return(new SortInterpreter(context, resource).Apply(enumerable));
            }

            return(data);
        }
コード例 #4
0
ファイル: SortContext.cs プロジェクト: slagusev/api
 protected SortContext(SortDirection direction, SortContext <TElement> child_context)
 {
     this.direction     = direction;
     this.child_context = child_context;
 }
コード例 #5
0
ファイル: SortContext.cs プロジェクト: pocketgems/Theraot
 protected SortContext(SortDirection direction, SortContext <TElement> childContext)
 {
     _direction    = direction;
     _childContext = childContext;
 }