Beispiel #1
0
        public void projection_does_not_include_not_authorized_columns()
        {
            var grid = new TargetGrid();

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

            var service = new StubFieldAccessService();

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

            var projection = grid.ToProjection(service);

            projection.As <IProjection <GridDefTarget> >().Accessors()
            .Select(x => x.Name)
            .ShouldHaveTheSameElementsAs("Count", "IsCool");
        }
Beispiel #2
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}]");
        }