Пример #1
0
 public void Copy()
 {
     foreach (ServiceControllerPermissionAccess scpa in AllAccess)
     {
         ServiceControllerPermission      scp  = new ServiceControllerPermission(PermissionState.None);
         ServiceControllerPermissionEntry scpe = new ServiceControllerPermissionEntry(scpa, "localhost", scpa.ToString());
         scp.PermissionEntries.Add(scpe);
         ServiceControllerPermission copy = (ServiceControllerPermission)scp.Copy();
         Assert.AreEqual(1, copy.PermissionEntries.Count, "Count==1");
         Assert.AreEqual(scpa, scp.PermissionEntries [0].PermissionAccess, scpa.ToString());
     }
 }
Пример #2
0
        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 ()");
        }