public void PermissionState_Unrestricted () { PermissionState ps = PermissionState.Unrestricted; DnsPermission dp = new DnsPermission (ps); Assert.IsTrue (dp.IsUnrestricted (), "IsUnrestricted"); SecurityElement se = dp.ToXml (); Assert.AreEqual ("true", se.Attribute ("Unrestricted"), "Xml-Unrestricted"); Assert.AreEqual (3, se.Attributes.Count, "Xml-Attributes#"); Assert.IsNull (se.Children, "Xml-Children"); DnsPermission copy = (DnsPermission)dp.Copy (); Assert.IsFalse (Object.ReferenceEquals (dp, copy), "ReferenceEquals"); Assert.AreEqual (dp.IsUnrestricted (), copy.IsUnrestricted (), "IsUnrestricted ()"); }
public void PermissionState_None () { PermissionState ps = PermissionState.None; DnsPermission dp = new DnsPermission (ps); Assert.IsFalse (dp.IsUnrestricted (), "IsUnrestricted"); SecurityElement se = dp.ToXml (); // only class and version are present Assert.AreEqual (2, se.Attributes.Count, "Xml-Attributes#"); Assert.IsNull (se.Children, "Xml-Children"); DnsPermission copy = (DnsPermission)dp.Copy (); Assert.IsFalse (Object.ReferenceEquals (dp, copy), "ReferenceEquals"); Assert.AreEqual (dp.IsUnrestricted (), copy.IsUnrestricted (), "IsUnrestricted ()"); }
public void PermissionState_Bad () { PermissionState ps = (PermissionState)Int32.MinValue; DnsPermission dp = new DnsPermission (ps); // no ArgumentException here Assert.IsFalse (dp.IsUnrestricted ()); }
public override bool IsSubsetOf(IPermission target) { DnsPermission dp = Cast(target); if (dp == null) { return(IsEmpty()); } return(dp.IsUnrestricted() || (m_noRestriction == dp.m_noRestriction)); }
public override IPermission Intersect(IPermission target) { DnsPermission dp = Cast(target); if (dp == null) { return(null); } if (IsUnrestricted() && dp.IsUnrestricted()) { return(new DnsPermission(PermissionState.Unrestricted)); } return(null); }
public override IPermission Union(IPermission target) { DnsPermission dp = Cast(target); if (dp == null) { return(Copy()); } if (IsUnrestricted() || dp.IsUnrestricted()) { return(new DnsPermission(PermissionState.Unrestricted)); } else { return(new DnsPermission(PermissionState.None)); } }