コード例 #1
0
        public void format_data_smoke_test()
        {
            var grid = new TargetGrid();

            grid.Column(x => x.Count);
            grid.Column(x => x.IsCool);
            grid.Column(x => x.Name);

            var data = new GridDefTarget[] {
                new GridDefTarget {
                    Count = 1, IsCool = true, Name = "Scooby"
                },
                new GridDefTarget {
                    Count = 2, IsCool = true, Name = "Velma"
                },
                new GridDefTarget {
                    Count = 3, IsCool = true, Name = "Daphne"
                },
            };

            var dicts = grid.As <IGridDefinition <GridDefTarget> >().FormatData(data);

            dicts.Select(x => x["Name"]).ShouldHaveTheSameElementsAs("Scooby", "Velma", "Daphne");
            dicts.Select(x => x["Count"]).ShouldHaveTheSameElementsAs(1, 2, 3);
        }
コード例 #2
0
        public void format_data_smoke_test()
        {
            var grid = new TargetGrid();

            grid.Column(x => x.Count);
            grid.Column(x => x.IsCool);
            grid.Column(x => x.Name);

            var data = new GridDefTarget[] {
                new GridDefTarget {
                    Count = 1, IsCool = true, Name = "Scooby"
                },
                new GridDefTarget {
                    Count = 2, IsCool = true, Name = "Velma"
                },
                new GridDefTarget {
                    Count = 3, IsCool = true, Name = "Daphne"
                },
            };

            IProjection <GridDefTarget> projection = grid.As <IGridDefinition <GridDefTarget> >().Projection.As <IProjection <GridDefTarget> >();


            var dicts = data.Select(x => {
                var node = new DictionaryMediaNode();

                projection.Write(new ProjectionContext <GridDefTarget>(new InMemoryServiceLocator(), x), node);

                return(node.Values);
            });

            dicts.Select(x => x["Name"]).ShouldHaveTheSameElementsAs("Scooby", "Velma", "Daphne");
            dicts.Select(x => x["Count"]).ShouldHaveTheSameElementsAs(1, 2, 3);
        }
コード例 #3
0
        public void select_data_source_url_with_paged_source()
        {
            var targetGrid = new TargetGrid();

            targetGrid.SourceIs <PagedSource>();

            targetGrid.As <IGridDefinition>().DetermineRunnerType().ShouldEqual(typeof(PagedGridRunner <GridDefTarget, TargetGrid, PagedSource, SpecialPagedQuery>));
        }
コード例 #4
0
        public void select_data_source_url_with_source_type_and_a_query()
        {
            var targetGrid = new TargetGrid();

            targetGrid.SourceIs <QueryGoodSource>();

            targetGrid.As <IGridDefinition>().DetermineRunnerType().ShouldEqual(typeof(GridRunner <GridDefTarget, TargetGrid, QueryGoodSource, DifferentClass>));
        }
コード例 #5
0
        public void select_data_source_url_with_source_type_and_no_query()
        {
            var targetGrid = new TargetGrid();

            targetGrid.SourceIs <SimpleGoodSource>();

            targetGrid.As <IGridDefinition>().DetermineRunnerType().ShouldEqual(typeof(GridRunner <GridDefTarget, TargetGrid, SimpleGoodSource>));
        }
コード例 #6
0
        public void create_column_json_with_data_elements()
        {
            var grid = new TargetGrid();

            grid.Column(x => x.Count);
            grid.Data(x => x.IsCool);
            grid.Column(x => x.Name);

            var json = grid.As <IGridDefinition>().ToColumnJson();

            json
            .ShouldEqual("[{name: \"Count\", field: \"Count\", id: \"Count\", sortable: true, frozen: false}, {name: \"Name\", field: \"Name\", id: \"Name\", sortable: true, frozen: false}]");
        }
コード例 #7
0
        public void create_all_frozen_columns_json()
        {
            var grid = new TargetGrid();

            grid.Column(x => x.Count).Frozen(true);
            grid.Column(x => x.IsCool).Frozen(true);
            grid.Column(x => x.Name).Frozen(true);

            var json = grid.As <IGridDefinition>().ToColumnJson();

            json
            .ShouldEqual("[{name: \"Count\", field: \"Count\", id: \"Count\", sortable: true, frozen: true}, {name: \"IsCool\", field: \"IsCool\", id: \"IsCool\", sortable: true, frozen: true}, {name: \"Name\", field: \"Name\", id: \"Name\", sortable: true, frozen: true}]");
        }
コード例 #8
0
        public void create_column_json()
        {
            var grid = new TargetGrid();

            grid.Column(x => x.Count);
            grid.Column(x => x.IsCool);
            grid.Column(x => x.Name);

            var json = grid.As <IGridDefinition>().ToColumnJson(new StubFieldAccessService());

            json
            .ShouldEqual("[{name: \"en-US_Count\", field: \"Count\", id: \"Count\", sortable: true, frozen: false}, {name: \"en-US_IsCool\", field: \"IsCool\", id: \"IsCool\", sortable: true, frozen: false}, {name: \"en-US_Name\", field: \"Name\", id: \"Name\", sortable: true, frozen: false}]");
        }
コード例 #9
0
        public void create_column_json_with_authorization_field_rights()
        {
            var grid = new TargetGrid();

            grid.Column(x => x.Count);
            grid.Data(x => x.IsCool);
            grid.Column(x => x.Name);
            grid.Column(x => x.Random);

            var service = new StubFieldAccessService();

            service.SetRights <GridDefTarget>(x => x.Random, AccessRight.None);
            service.SetRights <GridDefTarget>(x => x.Name, AccessRight.ReadOnly);

            var json = grid.As <IGridDefinition>().ToColumnJson(service);

            json
            .ShouldEqual("[{name: \"en-US_Count\", field: \"Count\", id: \"Count\", sortable: true, frozen: false}, {name: \"en-US_Name\", field: \"Name\", id: \"Name\", sortable: true, frozen: false}]");
        }