Ejemplo 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"]);
        }
Ejemplo n.º 2
0
        private static IDictionary <string, object> JsonForActionColumn <T>(Action <GridActionColumn <T> > configure)
            where T : class
        {
            var column = new GridActionColumn <T>(GridTestHelper.CreateGrid <T>());

            configure(column);
            return(column.CreateSerializer().Serialize());
        }
Ejemplo n.º 3
0
        private static IDictionary <string, object> JsonForForeignKeyColumn <T, TValue>(Expression <Func <T, TValue> > expression, SelectList data, Action <GridForeignKeyColumn <T, TValue> > configure)
            where T : class
        {
            var column = new GridForeignKeyColumn <T, TValue>(GridTestHelper.CreateGrid <T>(), expression, data);

            configure(column);
            return(column.CreateSerializer().Serialize());
        }
Ejemplo n.º 4
0
 public GridColumnBaseTests()
 {
     grid   = GridTestHelper.CreateGrid <Customer>();
     column = new Mock <GridColumnBase <Customer> >(grid)
     {
         CallBase = true
     };
 }
        public void Should_serialize_grouping()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            grid.Grouping.Enabled = true;

            Assert.Contains("grouping", new GridPluginSerializer(grid).Serialize());
        }
        public void Enabled_sets_the_enabled_property()
        {
            GridBindingSettings     settings = new GridBindingSettings(GridTestHelper.CreateGrid <Customer>());
            GridAjaxSettingsBuilder builder  = new GridAjaxSettingsBuilder(settings);

            builder.Enabled(true);

            Assert.True(settings.Enabled);
        }
Ejemplo n.º 7
0
        public void Should_serialize_group_expression()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            ((IGridBindingContext)grid).GroupDescriptors.Add(new GroupDescriptor
            {
                Member = "Id"
            });
            Assert.Equal("Id-asc", grid.Grouping.SerializeExpression());
        }
Ejemplo n.º 8
0
        public void Should_not_serialize_editor_html_in_server_binding_mode()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            grid.Editing.Enabled = true;

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

            Assert.False(result.ContainsKey("editor"));
        }
Ejemplo n.º 9
0
        public void Should_not_serialize_client_template_if_not_set()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            grid.Ajax.Enabled = true;

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

            Assert.False(result.ContainsKey("template"));
        }
        public void Should_not_serialize_confirm_delete_if_true()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            grid.Editing.Enabled = true;

            var result = grid.Editing.Serialize();

            Assert.False(result.ContainsKey("confirmDelete"));
        }
Ejemplo n.º 11
0
        public void Should_generate_columns_for_properties_of_nullable_bindable_type()
        {
            var grid = GridTestHelper.CreateGrid <NullableFoo>();

            grid.DataSource = Enumerable.Empty <NullableFoo>();
            var columnGenerator  = new GridColumnGenerator <NullableFoo>(grid);
            var generatedColumns = columnGenerator.GetColumns();

            generatedColumns.Count().ShouldEqual(1);
            generatedColumns.First().Member.ShouldEqual("Bar");
        }
        public void Should_not_serialize_ws_if_not_enabled()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            writer.Setup(w => w.AppendObject("ws", It.IsAny <IDictionary <string, string> >()));
            var serializer = new GridClientObjectSerializer <Customer>(grid);

            serializer.Serialize(writer.Object);

            writer.Verify(w => w.AppendObject("ws", It.IsAny <IDictionary <string, string> >()), Times.Never());
        }
        public void Should_serialize_confirm_delete_if_false()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            grid.Editing.Enabled = true;
            grid.Editing.DisplayDeleteConfirmation = false;

            var result = grid.Editing.Serialize();

            Assert.Equal(false, result["confirmDelete"]);
        }
        public void Should_serialize_default_item_if_ajax_binding()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            grid.Editing.Enabled = true;
            grid.Ajax.Enabled    = true;

            var result = grid.Editing.Serialize();

            result.ContainsKey("defaultDataItem").ShouldBeTrue();
        }
Ejemplo n.º 15
0
        public void Should_return_empty_collection_if_null_DataTable_is_provided()
        {
            DataTable dataTable = null;

            var grid = GridTestHelper.CreateGrid <DataRowView>();

            grid.DataSource = dataTable.WrapAsEnumerable();
            var dataTableColumnGenerator = new GridColumnGenerator <DataRowView>(grid);

            Assert.Empty(dataTableColumnGenerator.GetColumns());
        }
        public void Should_not_serialize_columns_if_empty()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            writer.Setup(w => w.AppendCollection("columns", It.IsAny <IEnumerable <IDictionary <string, object> > >()));

            var serializer = new GridClientObjectSerializer <Customer>(grid);

            serializer.Serialize(writer.Object);

            writer.Verify(w => w.AppendCollection("columns", It.IsAny <IEnumerable <IDictionary <string, object> > >()), Times.Never());
        }
        public void Should_not_serialize_sort_order_if_sorting_is_disabled()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            writer.Setup(w => w.Append("sortMode", It.IsAny <string>()));

            var serializer = new GridClientObjectSerializer <Customer>(grid);

            serializer.Serialize(writer.Object);

            writer.Verify(w => w.Append("sortMode", It.IsAny <string>()), Times.Never());
        }
        public void Should_not_serialize_plugins_if_none_are_enabled()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            writer.Setup(w => w.AppendCollection("plugins", It.IsAny <IEnumerable <string> >()));

            var serializer = new GridClientObjectSerializer <Customer>(grid);

            serializer.Serialize(writer.Object);

            writer.Verify(w => w.AppendCollection("plugins", It.IsAny <IEnumerable <string> >()), Times.Never());
        }
        public void Should_serialize_page_size_0_if_paging_is_not_enabled()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            writer.Setup(w => w.Append("pageSize", 0));

            var serializer = new GridClientObjectSerializer <Customer>(grid);

            serializer.Serialize(writer.Object);

            writer.VerifyAll();
        }
        public void Should_not_serialize_editing_if_not_enabled()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            writer.Setup(w => w.AppendObject("editing", It.IsAny <object>()));

            var serializer = new GridClientObjectSerializer <Customer>(grid);

            serializer.Serialize(writer.Object);

            writer.Verify(w => w.AppendObject("editing", It.IsAny <object>()), Times.Never());
        }
        public void Should_not_serialize_pageOnScroll_if_paging_disabled()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            writer.Setup(w => w.Append("pageOnScroll", It.IsAny <bool>()));

            var serializer = new GridClientObjectSerializer <Customer>(grid);

            serializer.Serialize(writer.Object);

            writer.Verify(w => w.Append("pageOnScroll", It.IsAny <bool>()), Times.Never());
        }
        public void Should_serialize_format_if_grouping_enabled()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            grid.Grouping.Enabled = true;

            writer.Setup(w => w.Append("urlFormat", It.IsAny <string>()));
            var serializer = new GridClientObjectSerializer <Customer>(grid);

            serializer.Serialize(writer.Object);

            writer.VerifyAll();
        }
        public void Should_serialize_web_service()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            grid.WebService.Enabled = true;

            writer.Setup(w => w.AppendObject("ws", It.IsAny <IDictionary <string, string> >()));
            var serializer = new GridClientObjectSerializer <Customer>(grid);

            serializer.Serialize(writer.Object);

            writer.VerifyAll();
        }
Ejemplo n.º 24
0
        public void Should_serialize_client_template_for_template_column()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            grid.Ajax.Enabled = true;
            var column = new GridTemplateColumn <Customer>(grid, delegate { });

            column.ClientTemplate = "<#= Id #>";

            var result = column.CreateSerializer().Serialize();

            Assert.Equal("<#= Id #>", result["template"]);
        }
        public void Should_serialize_plugins()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            grid.Grouping.Enabled = true;

            writer.Setup(w => w.AppendCollection("plugins", It.IsAny <IEnumerable <string> >()));

            var serializer = new GridClientObjectSerializer <Customer>(grid);

            serializer.Serialize(writer.Object);

            writer.VerifyAll();
        }
Ejemplo n.º 26
0
        public void Should_serialize_client_template()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            grid.Ajax.Enabled = true;
            var result = new GridBoundColumn <Customer, int>(grid, c => c.Id)
            {
                ClientTemplate = "<#= Id #>"
            }
            .CreateSerializer()
            .Serialize();

            Assert.Equal("<#= Id #>", result["template"]);
        }
        public void Should_serialize_selection()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            grid.Selection.Enabled = true;

            writer.Setup(w => w.Append("selectable", true));

            var serializer = new GridClientObjectSerializer <Customer>(grid);

            serializer.Serialize(writer.Object);

            writer.VerifyAll();
        }
        public void Should_serialize_columns()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            grid.Columns.Add(new GridBoundColumn <Customer, int>(grid, c => c.Id));

            writer.Setup(w => w.AppendCollection("columns", It.IsAny <IEnumerable <IDictionary <string, object> > >()));

            var serializer = new GridClientObjectSerializer <Customer>(grid);

            serializer.Serialize(writer.Object);

            writer.VerifyAll();
        }
        public void Should_serialize_pageOnScroll_if_paging_enabled()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            grid.Paging.Enabled = true;

            writer.Setup(w => w.Append("pageOnScroll", It.IsAny <bool>()));

            var serializer = new GridClientObjectSerializer <Customer>(grid);

            serializer.Serialize(writer.Object);

            writer.VerifyAll();
        }
        public void Should_not_serialize_format_in_client_binding()
        {
            var grid = GridTestHelper.CreateGrid <Customer>();

            grid.Grouping.Enabled = true;
            grid.Ajax.Enabled     = true;

            writer.Setup(w => w.Append("urlFormat", It.IsAny <string>()));
            var serializer = new GridClientObjectSerializer <Customer>(grid);

            serializer.Serialize(writer.Object);

            writer.Verify(w => w.Append("urlFormat", It.IsAny <string>()), Times.Never());
        }