public void PoliciesShouldCombine()
        {
            const string allowedRole     = "test role";
            var          roleRequirement = new RolesAuthorizationRequirement(new[] { allowedRole });
            var          rolePolicy      = new AuthorizationPolicy(new[] { roleRequirement }, new string[0]);

            var denyAnonymousRequirement = new DenyAnonymousAuthorizationRequirement();
            var denyAnonymousPolicy      = new AuthorizationPolicy(new[] { denyAnonymousRequirement }, new string[0]);

            var combinedPolicy = AuthorizationPolicy.Combine(rolePolicy, denyAnonymousPolicy);
            var requirements   = new HashSet <IAuthorizationRequirement>(combinedPolicy.Requirements);

            Assert.IsTrue(requirements.Contains(roleRequirement));
            Assert.IsTrue(requirements.Contains(denyAnonymousRequirement));
        }
 public void CombineShouldThrowWhenPoliciesEnumerableIsNull()
 {
     AuthorizationPolicy.Combine((IEnumerable <AuthorizationPolicy>)null);
 }
 public void CombineShouldThrowWhenPoliciesParametersIsNull()
 {
     AuthorizationPolicy[] policies = null;
     // ReSharper disable once ExpressionIsAlwaysNull because we want it to be null
     AuthorizationPolicy.Combine(policies);
 }