public void PermissionState_Unrestricted () { PermissionState ps = PermissionState.Unrestricted; ServiceControllerPermission scp = new ServiceControllerPermission (ps); Assert.AreEqual (0, scp.PermissionEntries.Count, "PermissionEntries"); Assert.IsTrue (scp.IsUnrestricted (), "IsUnrestricted"); SecurityElement se = scp.ToXml (); // only class and version are present Assert.AreEqual ("true", se.Attribute ("Unrestricted"), "Xml-Unrestricted"); Assert.IsNull (se.Children, "Xml-Children"); ServiceControllerPermission copy = (ServiceControllerPermission)scp.Copy (); Assert.IsFalse (Object.ReferenceEquals (scp, copy), "ReferenceEquals"); Assert.AreEqual (scp.PermissionEntries.Count, copy.PermissionEntries.Count, "copy-PermissionEntries"); Assert.AreEqual (scp.IsUnrestricted (), copy.IsUnrestricted (), "copy-IsUnrestricted ()"); }
public void FromXml_NoVersion () { ServiceControllerPermission scp = new ServiceControllerPermission (PermissionState.None); SecurityElement se = scp.ToXml (); SecurityElement w = new SecurityElement (se.Tag); w.AddAttribute ("class", se.Attribute ("class")); scp.FromXml (w); }
public void FromXml_WrongVersion () { ServiceControllerPermission scp = new ServiceControllerPermission (PermissionState.None); SecurityElement se = scp.ToXml (); se.Attributes.Remove ("version"); se.Attributes.Add ("version", "2"); scp.FromXml (se); }
public void FromXml_NoClass () { ServiceControllerPermission scp = new ServiceControllerPermission (PermissionState.None); SecurityElement se = scp.ToXml (); SecurityElement w = new SecurityElement (se.Tag); w.AddAttribute ("version", se.Attribute ("version")); scp.FromXml (w); // doesn't even care of the class attribute presence }
public void FromXml_WrongClass () { ServiceControllerPermission scp = new ServiceControllerPermission (PermissionState.None); SecurityElement se = scp.ToXml (); SecurityElement w = new SecurityElement (se.Tag); w.AddAttribute ("class", "Wrong" + se.Attribute ("class")); w.AddAttribute ("version", se.Attribute ("version")); scp.FromXml (w); // doesn't care of the class name at that stage // anyway the class has already be created so... }
public void FromXml_WrongTagCase () { ServiceControllerPermission scp = new ServiceControllerPermission (PermissionState.None); SecurityElement se = scp.ToXml (); se.Tag = "IPERMISSION"; // instead of IPermission scp.FromXml (se); // note: normally IPermission classes (in corlib) DO care about the // IPermission tag }