public void Copy()
        {
            PermissionSet           none = new PermissionSet(PermissionState.None);
            PermissionSet           unr  = new PermissionSet(PermissionState.Unrestricted);
            PermissionSetCollection psc  = new PermissionSetCollection();
            PermissionSetCollection copy = psc.Copy();

            Assert.AreEqual(0, copy.PermissionSets.Count, "Count-0");
            psc.Add(none);
            Assert.AreEqual(0, copy.PermissionSets.Count, "Count-0b");
            copy = psc.Copy();
            Assert.AreEqual(1, copy.PermissionSets.Count, "Count-1");
            psc.Add(none);              // re-add same permissionset
            Assert.AreEqual(1, copy.PermissionSets.Count, "Count-1b");
            copy = psc.Copy();
            Assert.AreEqual(2, copy.PermissionSets.Count, "Count-2");
            psc.Add(unr);
            Assert.AreEqual(2, copy.PermissionSets.Count, "Count-2b");
            copy = psc.Copy();
            Assert.AreEqual(3, copy.PermissionSets.Count, "Count-3");
            Assert.AreEqual(3, copy.Count, "Count-3");
        }
        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");
        }