Ejemplo n.º 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);
        }
        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);
        }
Ejemplo n.º 3
0
        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);
        }
Ejemplo n.º 4
0
 protected SortContext(SortDirection direction, SortContext <TElement> child_context)
 {
     this.direction     = direction;
     this.child_context = child_context;
 }
Ejemplo n.º 5
0
 protected SortContext(SortDirection direction, SortContext <TElement> childContext)
 {
     _direction    = direction;
     _childContext = childContext;
 }