public void Test_And_Mixed() { AndSpecification s = new AndSpecification(); s.Add(AlwaysFalse); s.Add(AlwaysTrue); Assert.IsFalse(s.Test(null).Success); }
public void Test_And_AllTrue() { AndSpecification s = new AndSpecification(); s.Add(AlwaysTrue); s.Add(AlwaysTrue); Assert.IsTrue(s.Test(null).Success); }
/// <summary> /// Applies permissions represented by this attribute to an action instance, via the specified <see cref="IActionBuildingContext"/>. /// </summary> public override void Apply(IActionBuildingContext builder) { // if this is the first occurence of this attribute, create the parent spec if (builder.Action.PermissionSpecification == null) { builder.Action.PermissionSpecification = new OrSpecification(); } // combine the specified tokens with AND logic AndSpecification and = new AndSpecification(); foreach (string token in _authorityTokens) { and.Add(new PrincipalPermissionSpecification(token)); } // combine this spec with any previous occurence of this attribute using OR logic ((OrSpecification)builder.Action.PermissionSpecification).Add(and); }