Exemplo n.º 1
0
        public void Should_serialize_filters()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            ((IGridBindingContext)grid).FilterDescriptors.Add(new CompositeFilterDescriptor
            {
                LogicalOperator   = FilterCompositionLogicalOperator.And,
                FilterDescriptors =
                {
                    new FilterDescriptor
                    {
                        Member   = "Id",
                        Operator = FilterOperator.IsEqualTo,
                        Value    = 1
                    },
                    new FilterDescriptor
                    {
                        Member   = "Id",
                        Operator = FilterOperator.IsGreaterThan,
                        Value    = 1
                    }
                }
            });

            var column = new GridBoundColumn <Customer, int>(grid, c => c.Id);
            var result = column.CreateSerializer().Serialize();

            var filters = ((IList <IDictionary <string, object> >)result["filters"]);

            Assert.Equal("eq", filters[0]["operator"]);
            Assert.Equal(1, filters[0]["value"]);

            Assert.Equal("gt", filters[1]["operator"]);
            Assert.Equal(1, filters[1]["value"]);
        }
Exemplo n.º 2
0
        private static IDictionary <string, object> JsonForBoundColumn <T, TValue>(Expression <Func <T, TValue> > expression, Action <GridBoundColumn <T, TValue> > configure)
            where T : class
        {
            var column = new GridBoundColumn <T, TValue>(GridTestHelper.CreateGrid <T>(), expression);

            configure(column);
            return(column.CreateSerializer().Serialize());
        }
Exemplo n.º 3
0
        public void Should_serialize_order_if_sorted()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            ((IGridBindingContext)grid).SortDescriptors.Add(new SortDescriptor
            {
                Member        = "Id",
                SortDirection = System.ComponentModel.ListSortDirection.Descending
            });

            var column = new GridBoundColumn <Customer, int>(grid, c => c.Id);
            var result = column.CreateSerializer().Serialize();

            Assert.Equal("desc", result["order"]);
        }