public void Constructor()
        {
            PermissionSetCollection psc = new PermissionSetCollection();

            Assert.AreEqual(0, psc.Count, "Count");
            Assert.IsFalse(psc.IsSynchronized, "IsSynchronized");
            Assert.AreEqual(0, psc.PermissionSets.Count, "PermissionSets.Count");
            Assert.AreEqual(psc.ToXml().ToString(), psc.ToString(), "ToXml().ToString()==ToString()");
            Assert.IsNotNull(psc.GetEnumerator(), "GetEnumerator");
        }
        public void Copy_References()
        {
            PermissionSet           none = new PermissionSet(PermissionState.None);
            PermissionSetCollection psc  = new PermissionSetCollection();

            psc.Add(none);
            PermissionSetCollection copy = psc.Copy();

            Assert.AreEqual(1, copy.PermissionSets.Count, "Count-1");

            string before = psc.ToString();

            none.AddPermission(new SecurityPermission(SecurityPermissionFlag.Assertion));

            Assert.AreEqual(none.ToString(), psc.PermissionSets[0].ToString(), "psc");
            Assert.AreEqual(before, copy.ToString(), "copy");
        }
        public void FromXml_Roundtrip()
        {
            PermissionSetCollection psc = new PermissionSetCollection();
            string          expected    = psc.ToString();
            SecurityElement se          = psc.ToXml();

            psc.FromXml(se);
            string actual = psc.ToString();

            Assert.AreEqual(expected, actual, "Empty");

            PermissionSet none = new PermissionSet(PermissionState.None);

            psc.Add(none);
            expected = psc.ToString();
            se       = psc.ToXml();
            psc.FromXml(se);
            actual = psc.ToString();
            Assert.AreEqual(expected, actual, "1-None");

            none.AddPermission(new SecurityPermission(SecurityPermissionFlag.Assertion));
            expected = psc.ToString();
            se       = psc.ToXml();
            psc.FromXml(se);
            actual = psc.ToString();
            Assert.AreEqual(expected, actual, "1-Assertion");
            Assert.AreEqual(1, psc.Count, "1");

            PermissionSet unr = new PermissionSet(PermissionState.Unrestricted);

            psc.Add(unr);
            expected = psc.ToString();
            se       = psc.ToXml();
            psc.FromXml(se);
            actual = psc.ToString();
            Assert.AreEqual(expected, actual, "2-Assertion+Unrestricted");
            Assert.AreEqual(2, psc.Count, "2");
        }