public void PermissionStateNone () { UIPermission uip = new UIPermission (PermissionState.None); Assert.AreEqual (UIPermissionClipboard.NoClipboard, uip.Clipboard, "Clipboard"); Assert.AreEqual (UIPermissionWindow.NoWindows, uip.Window, "Window"); Assert.IsFalse (uip.IsUnrestricted (), "IsUnrestricted"); SecurityElement se = uip.ToXml (); Assert.IsNull (se.Attribute ("Unrestricted"), "Xml-Unrestricted"); UIPermission copy = (UIPermission)uip.Copy (); Assert.AreEqual (UIPermissionClipboard.NoClipboard, uip.Clipboard, "Copy-Clipboard"); Assert.AreEqual (UIPermissionWindow.NoWindows, uip.Window, "Copy-Window"); Assert.IsFalse (uip.IsUnrestricted (), "Copy-IsUnrestricted"); }
public void PermissionStateUnrestricted () { UIPermission uip = new UIPermission (PermissionState.Unrestricted); Assert.AreEqual (UIPermissionClipboard.AllClipboard, uip.Clipboard, "Clipboard"); Assert.AreEqual (UIPermissionWindow.AllWindows, uip.Window, "Window"); Assert.IsTrue (uip.IsUnrestricted (), "IsUnrestricted"); SecurityElement se = uip.ToXml (); Assert.AreEqual ("true", se.Attribute ("Unrestricted"), "Xml-Unrestricted"); UIPermission copy = (UIPermission)uip.Copy (); Assert.AreEqual (UIPermissionClipboard.AllClipboard, uip.Clipboard, "Copy-Clipboard"); Assert.AreEqual (UIPermissionWindow.AllWindows, uip.Window, "Copy-Window"); Assert.IsTrue (uip.IsUnrestricted (), "Copy-IsUnrestricted"); }
public void FromXml_NoVersion () { UIPermission uip = new UIPermission (PermissionState.None); SecurityElement se = uip.ToXml (); SecurityElement w = new SecurityElement (se.Tag); w.AddAttribute ("class", se.Attribute ("class")); uip.FromXml (w); }
public void FromXml_NoClass () { UIPermission uip = new UIPermission (PermissionState.None); SecurityElement se = uip.ToXml (); SecurityElement w = new SecurityElement (se.Tag); w.AddAttribute ("version", se.Attribute ("version")); uip.FromXml (w); // doesn't even care of the class attribute presence }
public void FromXml_WrongClass () { UIPermission uip = new UIPermission (PermissionState.None); SecurityElement se = uip.ToXml (); SecurityElement w = new SecurityElement (se.Tag); w.AddAttribute ("class", "Wrong" + se.Attribute ("class")); w.AddAttribute ("version", se.Attribute ("version")); uip.FromXml (w); // doesn't care of the class name at that stage // anyway the class has already be created so... }
public void FromXml_WrongTagCase () { UIPermission uip = new UIPermission (PermissionState.None); SecurityElement se = uip.ToXml (); se.Tag = "IPERMISSION"; // instead of IPermission uip.FromXml (se); }
public void Unrestricted () { UIPermission uip = new UIPermission (PermissionState.None); SecurityElement se = uip.ToXml (); // attribute value is not case-sensitive se.AddAttribute ("Unrestricted", "TRUE"); uip.FromXml (se); Assert.IsTrue (uip.IsUnrestricted (), "IsUnrestricted-TRUE"); uip = new UIPermission (PermissionState.None); // attribute name is not case-sensitive either!!! se.AddAttribute ("UNRESTRICTED", "TRUE"); uip.FromXml (se); Assert.IsTrue (uip.IsUnrestricted (), "IsUnrestricted-UPPER"); }