Exemplo n.º 1
0
        public void FromXml_NoName()
        {
            NamedPermissionSet nps = new NamedPermissionSet(name, PermissionState.None);
            SecurityElement    se  = nps.ToXml();

            SecurityElement w = new SecurityElement(se.Tag);

            w.AddAttribute("class", se.Attribute("class"));
            w.AddAttribute("version", "1");
            nps.FromXml(w);

            // having a null name can badly influence the rest of the class code
            Assert.IsNull(nps.Name, "Name");
            NamedPermissionSet copy = (NamedPermissionSet)nps.Copy();

            Assert.IsNull(copy.Name, "Copy.Name");

            copy = nps.Copy("name");
            Assert.AreEqual("name", copy.Name, "Copy(Name).Name");

            se = nps.ToXml();
            Assert.IsNull(se.Attribute("Name"), "Name attribute");
#if NET_2_0
            Assert.AreEqual(0, nps.GetHashCode(), "GetHashCode");
            Assert.IsTrue(nps.Equals(nps), "Equals-self");
#endif
        }
Exemplo n.º 2
0
 public static void NamedPermissionSetCallMethods()
 {
     NamedPermissionSet nps = new NamedPermissionSet("Test");
     PermissionSet ps = nps.Copy();
     NamedPermissionSet nps2 = nps.Copy("Test");
     nps.Equals(nps2);
     int hash = nps.GetHashCode();
     SecurityElement se = new SecurityElement("");
     nps.FromXml(se);
     se = nps.ToXml();
 }
Exemplo n.º 3
0
        public static void NamedPermissionSetCallMethods()
        {
            NamedPermissionSet nps  = new NamedPermissionSet("Test");
            PermissionSet      ps   = nps.Copy();
            NamedPermissionSet nps2 = nps.Copy("Test");

            nps.Equals(nps2);
            int             hash = nps.GetHashCode();
            SecurityElement se   = new SecurityElement("");

            nps.FromXml(se);
            se = nps.ToXml();
        }
Exemplo n.º 4
0
        public void Equals()
        {
            NamedPermissionSet psn = new NamedPermissionSet(name, PermissionState.None);
            NamedPermissionSet psu = new NamedPermissionSet(name, PermissionState.Unrestricted);

            Assert.IsTrue(!psn.Equals(psu), "psn!=psu");
            Assert.IsTrue(!psu.Equals(psn), "psu!=psn");
            NamedPermissionSet cpsn = (NamedPermissionSet)psn.Copy();

            Assert.IsTrue(cpsn.Equals(psn), "cpsn==psn");
            Assert.IsTrue(psn.Equals(cpsn), "psn==cpsn");
            NamedPermissionSet cpsu = (NamedPermissionSet)psu.Copy();

            Assert.IsTrue(cpsu.Equals(psu), "cpsu==psu");
            Assert.IsTrue(psu.Equals(cpsu), "psu==cpsu");
            cpsn.Description = sentinel;
            Assert.IsTrue(cpsn.Equals(psn), "cpsn+desc==psn");
            Assert.IsTrue(psn.Equals(cpsn), "psn==cpsn+desc");
            cpsn.Description = sentinel;
            Assert.IsTrue(cpsu.Equals(psu), "cpsu+desc==psu");
            Assert.IsTrue(psu.Equals(cpsu), "psu==cpsu+desc");
        }