public void FromXml_WrongTagCase() { ZoneIdentityPermission zip = new ZoneIdentityPermission(PermissionState.None); SecurityElement se = zip.ToXml(); se.Tag = "IPERMISSION"; // instead of IPermission zip.FromXml(se); }
public void FromXml_NoVersion() { ZoneIdentityPermission zip = new ZoneIdentityPermission(PermissionState.None); SecurityElement se = zip.ToXml(); SecurityElement w = new SecurityElement(se.Tag); w.AddAttribute("class", se.Attribute("class")); zip.FromXml(w); }
public void FromXml_NoClass() { ZoneIdentityPermission zip = new ZoneIdentityPermission(PermissionState.None); SecurityElement se = zip.ToXml(); SecurityElement w = new SecurityElement(se.Tag); w.AddAttribute("version", se.Attribute("version")); zip.FromXml(w); // doesn't even care of the class attribute presence }
public static void ZoneIdentityPermissionCallMethods() { ZoneIdentityPermission zip = new ZoneIdentityPermission(new PermissionState()); ZoneIdentityPermission zip2 = new ZoneIdentityPermission(new SecurityZone()); IPermission ip = zip.Copy(); IPermission ip2 = zip.Intersect(ip); bool testbool = zip.IsSubsetOf(ip); SecurityElement se = new SecurityElement(""); zip.FromXml(se); se = zip.ToXml(); }
public void FromXml_WrongClass() { ZoneIdentityPermission zip = new ZoneIdentityPermission(PermissionState.None); SecurityElement se = zip.ToXml(); SecurityElement w = new SecurityElement(se.Tag); w.AddAttribute("class", "Wrong" + se.Attribute("class")); w.AddAttribute("version", se.Attribute("version")); zip.FromXml(w); // doesn't care of the class name at that stage // anyway the class has already be created so... }
//</Snippet5> //<Snippet6> // ToXml creates an XML encoding of the permission and its current state; FromXml reconstructs a // permission with the specified state from the XML encoding. private static void ToFromXmlDemo() { ZoneIdentityPermission zoneIdPerm1 = new ZoneIdentityPermission(SecurityZone.Intranet); ZoneIdentityPermission zoneIdPerm2 = new ZoneIdentityPermission(PermissionState.None); zoneIdPerm2.FromXml(zoneIdPerm1.ToXml()); bool result = zoneIdPerm2.Equals(zoneIdPerm1); if (result) { Console.WriteLine("Result of ToFromXml = " + zoneIdPerm2.ToString()); } else { Console.WriteLine(zoneIdPerm2.ToString()); Console.WriteLine(zoneIdPerm1.ToString()); } }
private ZoneIdentityPermission BasicTestZone(SecurityZone zone, bool special) { ZoneIdentityPermission zip = new ZoneIdentityPermission(zone); Assert.AreEqual(zone, zip.SecurityZone, "SecurityZone"); ZoneIdentityPermission copy = (ZoneIdentityPermission)zip.Copy(); Assert.IsTrue(Same(zip, copy), "Equals-Copy"); Assert.IsTrue(zip.IsSubsetOf(copy), "IsSubset-1"); Assert.IsTrue(copy.IsSubsetOf(zip), "IsSubset-2"); if (special) { Assert.IsFalse(zip.IsSubsetOf(null), "IsSubset-Null"); } IPermission intersect = zip.Intersect(copy); if (special) { Assert.IsTrue(intersect.IsSubsetOf(zip), "IsSubset-3"); Assert.IsFalse(Object.ReferenceEquals(zip, intersect), "!ReferenceEquals1"); Assert.IsTrue(intersect.IsSubsetOf(copy), "IsSubset-4"); Assert.IsFalse(Object.ReferenceEquals(copy, intersect), "!ReferenceEquals2"); } Assert.IsNull(zip.Intersect(null), "Intersect with null"); intersect = zip.Intersect(new ZoneIdentityPermission(PermissionState.None)); Assert.IsNull(intersect, "Intersect with PS.None"); // note: can't be tested with PermissionState.Unrestricted // XML roundtrip SecurityElement se = zip.ToXml(); copy.FromXml(se); Assert.IsTrue(Same(zip, copy), "Equals-Xml"); return(zip); }
public void FromXml_Null() { ZoneIdentityPermission zip = new ZoneIdentityPermission(PermissionState.None); zip.FromXml(null); }