public void IsSubset_Self() { UrlIdentityPermission uip = new UrlIdentityPermission(PermissionState.None); Assert.IsTrue(uip.IsSubsetOf(uip), "None"); foreach (string s in GoodUrls) { uip.Url = s; Assert.IsTrue(uip.IsSubsetOf(uip), s); } }
public void IsSubset_Null() { UrlIdentityPermission uip = new UrlIdentityPermission(PermissionState.None); Assert.IsTrue(uip.IsSubsetOf(null), "Empty"); foreach (string s in GoodUrls) { uip.Url = s; Assert.IsFalse(uip.IsSubsetOf(null), s); } }
public void IsSubset_Different() { UrlIdentityPermission uip1 = new UrlIdentityPermission(GoodUrls [0]); UrlIdentityPermission uip2 = new UrlIdentityPermission(GoodUrls [1]); Assert.IsFalse(uip1.IsSubsetOf(uip2), "Mono subset Novell"); Assert.IsFalse(uip2.IsSubsetOf(uip1), "Novell subset Mono"); }
public static void UrlIdentityPermissionCallMethods() { UrlIdentityPermission uip = new UrlIdentityPermission(new PermissionState()); UrlIdentityPermission uip2 = new UrlIdentityPermission("testsite"); IPermission ip = uip.Copy(); IPermission ip2 = uip.Intersect(ip); bool testbool = uip.IsSubsetOf(ip); ip2 = uip.Union(ip); SecurityElement se = new SecurityElement(""); uip.FromXml(se); se = uip.ToXml(); }
public void IsSubset_None() { // IsSubset with none // a. source (this) is none -> target is never a subset UrlIdentityPermission uip1 = new UrlIdentityPermission(PermissionState.None); UrlIdentityPermission uip2 = new UrlIdentityPermission(PermissionState.None); foreach (string s in GoodUrls) { uip1.Url = s; Assert.IsFalse(uip1.IsSubsetOf(uip2), "target " + s); } uip1 = new UrlIdentityPermission(PermissionState.None); // b. destination (target) is none -> target is always a subset foreach (string s in GoodUrls) { uip2.Url = s; Assert.IsFalse(uip2.IsSubsetOf(uip1), "source " + s); } }
// <Snippet2> // IsSubsetOf determines whether the current permission is a subset of the specified permission. private static void IsSubsetOfDemo() { //<Snippet8> UrlIdentityPermission permIdPerm1 = new UrlIdentityPermission("http://www.fourthcoffee.com/process/"); //</Snippet8> UrlIdentityPermission permIdPerm2 = new UrlIdentityPermission("http://www.fourthcoffee.com/*"); if (permIdPerm1.IsSubsetOf(permIdPerm2)) { Console.WriteLine(permIdPerm1.Url + " is a subset of " + permIdPerm2.Url); } else { Console.WriteLine(permIdPerm1.Url + " is not a subset of " + permIdPerm2.Url); } if (permIdPerm2.IsSubsetOf(permIdPerm1)) { Console.WriteLine(permIdPerm2.Url + " is a subset of " + permIdPerm1.Url); } else { Console.WriteLine(permIdPerm2.Url + " is not a subset of " + permIdPerm1.Url); } }
public static void UrlIdentityPermissionCallMethods() { UrlIdentityPermission uip = new UrlIdentityPermission(new PermissionState()); UrlIdentityPermission uip2 = new UrlIdentityPermission("testsite"); IPermission ip = uip.Copy(); IPermission ip2 = uip.Intersect(ip); bool testbool = uip.IsSubsetOf(ip); ip2 = uip.Union(ip); SecurityElement se = new SecurityElement(""); uip.FromXml(se); se = uip.ToXml(); }