public static void UnionCodeGroupCallMethods() { UnionCodeGroup ucg = new UnionCodeGroup(new GacMembershipCondition(), new PolicyStatement(new PermissionSet(new PermissionState()))); CodeGroup cg = ucg.Copy(); PolicyStatement ps = ucg.Resolve(new Evidence()); cg = ucg.ResolveMatchingCodeGroups(new Evidence()); }
public void CopyWithChildren() { UnionCodeGroup cgChild = new UnionCodeGroup(new AllMembershipCondition(), new PolicyStatement(new PermissionSet(PermissionState.Unrestricted))); UnionCodeGroup cg = new UnionCodeGroup(new AllMembershipCondition(), new PolicyStatement(new PermissionSet(PermissionState.None))); cg.AddChild(cgChild); UnionCodeGroup cg2 = (UnionCodeGroup)cg.Copy(); Assert.AreEqual(cg.Children.Count, cg2.Children.Count, "Children"); Assert.AreEqual(cg.ToXml().ToString(), cg2.ToXml().ToString(), "ToXml"); }
public void Copy() { UnionCodeGroup cg = new UnionCodeGroup(new AllMembershipCondition(), new PolicyStatement(new PermissionSet(PermissionState.None))); UnionCodeGroup cg2 = (UnionCodeGroup)cg.Copy(); Assert.AreEqual(cg.AttributeString, cg2.AttributeString, "AttributeString"); Assert.AreEqual(cg.Children.Count, cg2.Children.Count, "Children"); Assert.AreEqual(cg.Description, cg2.Description, "Description"); Assert.AreEqual(cg.MergeLogic, cg2.MergeLogic, "MergeLogic"); Assert.AreEqual(cg.Name, cg2.Name, "Name"); Assert.AreEqual(cg.PermissionSetName, cg2.PermissionSetName, "PermissionSetName"); Assert.AreEqual(cg.ToXml().ToString(), cg2.ToXml().ToString(), "ToXml"); }
public void ResolveMatchingCodeGroups_ThreeLevel() { UnionCodeGroup level1 = new UnionCodeGroup(new AllMembershipCondition(), new PolicyStatement(new PermissionSet(PermissionState.None))); CodeGroup level2 = level1.Copy(); level1.AddChild(level2); UnionCodeGroup level3 = new UnionCodeGroup(new ZoneMembershipCondition(SecurityZone.Untrusted), new PolicyStatement(new PermissionSet(PermissionState.Unrestricted))); level2.AddChild(level3); CodeGroup match = level1.ResolveMatchingCodeGroups(new Evidence()); Assert.IsNotNull(match, "Match"); Assert.IsTrue(match.Equals(level1, false), "Equals(false)"); // Equals (true) isn't a deep compare (just one level) Assert.IsTrue(match.Equals(level1, true), "Equals(true)"); }