Exemple #1
0
 public void ApplyRestriction(IDataRestriction <T> restriction)
 {
     restriction.Apply(this);
     if (!CanView && DenyingRestriction == null)
     {
         DenyingRestriction = restriction;
     }
 }
Exemple #2
0
        public void should_not_vote_if_the_request_does_not_contain_the_type_the_restriction_applies_to()
        {
            _theCase = new Case
            {
                Condition = "Open",
                Title     = "A Different Title"
            };
            var dataRestrictions = new IDataRestriction <Case>[]
            {
                new CasePropertyRestriction(x => x.Condition, "Open"),
            };

            Services.InjectArray(dataRestrictions);
            _fubuRequest = MockFor <IFubuRequest>();
            _fubuRequest.Stub(x => x.Get <Case>()).Return(new Case());
            ClassUnderTest.RightsFor(_fubuRequest).ShouldEqual(AuthorizationRight.None);
        }
Exemple #3
0
        public void should_deny_access_if_any_of_the_data_restrictions_deny_it()
        {
            _theCase = new Case
            {
                Condition = "Open",
                Title     = "A Different Title"
            };
            var dataRestrictions = new IDataRestriction <Case>[]
            {
                new CasePropertyRestriction(x => x.Condition, "Open"),
                new CasePropertyRestriction(x => x.Title, "The Title") // does not match, should deny
            };

            Services.InjectArray(dataRestrictions);
            _fubuRequest = MockFor <IFubuRequest>();
            _fubuRequest.Stub(x => x.Get <Case>()).Return(_theCase);
            ClassUnderTest.RightsFor(_fubuRequest).ShouldEqual(AuthorizationRight.Deny);
        }
Exemple #4
0
 public int Count(IServiceLocator services, IDataRestriction <TEntity> restriction)
 {
     return(Count(services, x => x.ApplyRestrictions(restriction.Apply)));
 }
Exemple #5
0
 public int Count <TEntity>(IDataRestriction <TEntity> restriction) where TEntity : DomainEntity
 {
     return(BuildGrid().As <ISmartGrid <TEntity> >().Count(_services, restriction));
 }
        // TODO -- eliminate some of the duplication
        // More testing.
        // This is well tested in Dovetail code, but want tests in fastpack code where it belongs
        public int RecordCountFor <TGrid, TEntity>(IDataRestriction <TEntity> restriction, params object[] arguments) where TGrid : ISmartGrid <TEntity> where TEntity : DomainEntity
        {
            var harness = getHarness <TGrid>(arguments);

            return(harness.Count(restriction));
        }