public void GetHashCode_() { NamedPermissionSet psn = new NamedPermissionSet(name, PermissionState.None); int nhc = psn.GetHashCode(); NamedPermissionSet psu = new NamedPermissionSet(name, PermissionState.Unrestricted); int uhc = psu.GetHashCode(); Assert.IsTrue(nhc != uhc, "GetHashCode-1"); psn.Description = sentinel; Assert.IsTrue(psn.GetHashCode() == nhc, "GetHashCode-2"); psu.Description = sentinel; Assert.IsTrue(psu.GetHashCode() == uhc, "GetHashCode-3"); }
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 }
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(); }