Example #1
0
    public void Permission_InvalidArguments()
    {
        PolicyPermission permission = new PolicyPermission("abc");

        IPermission[] values = new IPermission[] {
          null,
          new PrincipalPermission("abc", "xyz")
        };
        Action<IPermission>[] tests = new Action<IPermission>[] {
          (value) => permission.Intersect(value),
        (value) => permission.Union(value),
        (value) => permission.IsSubsetOf(value)
        };

        for (Int32 i = 0; i != tests.Length; ++i)
          for (Int32 j = 0; j != values.Length; ++j)
        Assert.Throws(typeof(ArgumentNullException),
              () => tests[i](values[j]));
    }
Example #2
0
    public void SetOperations_CorrectValues()
    {
        IPermission p1 = new PolicyPermission("a");
        IPermission p2 = new PolicyPermission("b");
        IPermission p3 = p1.Union(p2);
        IPermission p4 = p1.Intersect(p3);
        IPermission p5 = p1.Intersect(p2);
        IPermission p6 = p1.Union(p1);

        SetShouldBe(p1, new String[] { "a" });
        SetShouldBe(p2, new String[] { "b" });
        SetShouldBe(p3, new String[] { "a", "b" });
        SetShouldBe(p4, new String[] { "a" });
        Assert.IsNull(p5);
        SetShouldBe(p6, new String[] { "a" });
        Assert.IsTrue(p1.IsSubsetOf(p1));
        Assert.IsTrue(p1.IsSubsetOf(p3));
        Assert.IsFalse(p3.IsSubsetOf(p1));
    }