* PermissionSetCollectionTest.cs: Added tests for to see if alternates
authorSebastien Pouliot <sebastien@ximian.com>
Mon, 10 Jan 2005 18:50:34 +0000 (18:50 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Mon, 10 Jan 2005 18:50:34 +0000 (18:50 -0000)
IList implementation (e.g. non-ArrayList) are supported as this
affects where we must check for exceptions.

svn path=/trunk/mcs/; revision=38637

mcs/class/corlib/Test/System.Security/ChangeLog
mcs/class/corlib/Test/System.Security/PermissionSetCollectionTest.cs

index 22806e2ad2931eaea8961a9942ef95c03c14402b..f0232a95e4cefa96b3d9d6aba6865a398ff72342 100644 (file)
@@ -1,5 +1,8 @@
 2005-01-10  Sebastien Pouliot  <sebastien@ximian.com>
 
+       * PermissionSetCollectionTest.cs: Added tests for to see if alternates
+       IList implementation (e.g. non-ArrayList) are supported as this 
+       affects where we must check for exceptions.
        * SecurityElementTest.cs: Add new tests for 2.0 methods. Adapted 
        existing tests to deal with the fact that 2.0 doesn't indent the XML
        attributes and child elements.
index db6b999891ef4664d93efcbbedc082c6641f9419..9ab6eca42ac9e1241af1017f37d20ed41b013d10 100644 (file)
@@ -35,7 +35,88 @@ using System.Collections;
 using System.Security;
 using System.Security.Permissions;
 
-namespace MonoTests.System.Security {
+namespace MonoTests.System.Security {\r
+\r
+       // "alternate" IList implementation\r
+       class TestList : IList {\r
+\r
+               private IList l;\r
+\r
+               public TestList ()\r
+               {\r
+                       l = (IList) new ArrayList ();\r
+               }\r
+\r
+               public int Add (object value)\r
+               {\r
+                       return l.Add (value);\r
+               }\r
+\r
+               public void Clear ()\r
+               {\r
+                       l.Clear ();\r
+               }\r
+\r
+               public bool Contains (object value)\r
+               {\r
+                       return l.Contains (value);\r
+               }\r
+\r
+               public int IndexOf (object value)\r
+               {\r
+                       return l.IndexOf (value);\r
+               }\r
+\r
+               public void Insert (int index, object value)\r
+               {\r
+                       l.Insert (index, value);\r
+               }\r
+\r
+               public bool IsFixedSize {\r
+                       get { return l.IsFixedSize; }\r
+               }\r
+\r
+               public bool IsReadOnly {\r
+                       get { return l.IsReadOnly; }\r
+               }\r
+\r
+               public void Remove (object value)\r
+               {\r
+                       l.Remove (value);\r
+               }\r
+\r
+               public void RemoveAt (int index)\r
+               {\r
+                       l.RemoveAt (index);\r
+               }\r
+\r
+               public object this [int index] {\r
+                       get { return l [index]; }\r
+                       set { l [index] = value; }\r
+               }\r
+\r
+               public void CopyTo (Array array, int index)\r
+               {\r
+                       l.CopyTo (array, index);\r
+               }\r
+\r
+               public int Count {\r
+                       get { return l.Count; }\r
+               }\r
+\r
+               public bool IsSynchronized {\r
+                       get { return l.IsSynchronized; }\r
+               }\r
+\r
+               public object SyncRoot {\r
+                       get { return l.SyncRoot; }\r
+               }\r
+\r
+               public IEnumerator GetEnumerator ()\r
+               {\r
+                       return l.GetEnumerator ();\r
+               }\r
+       }
 
        [TestFixture]
        public class PermissionSetCollectionTest {
@@ -227,6 +308,24 @@ namespace MonoTests.System.Security {
                        PermissionSet ps = psc.GetSet (0);
                        Assert.AreEqual (unr.ToString (), ps.ToString (), "Same XML");
                        Assert.IsTrue (Object.ReferenceEquals (unr, ps), "Same Object Reference");
+               }\r
+\r
+               [Test]\r
+               public void PermissionSets_SetArrayList ()\r
+               {\r
+                       PermissionSetCollection psc = new PermissionSetCollection ();\r
+                       PermissionSet unr = new PermissionSet (PermissionState.Unrestricted);\r
+                       psc.Add (unr);\r
+                       Assert.AreEqual (1, psc.Count, "original ArrayList");\r
+                       psc.PermissionSets = new ArrayList ();\r
+                       Assert.AreEqual (0, psc.Count, "new ArrayList");\r
+               }\r
+\r
+               [Test]\r
+               public void PermissionSets_SetTestList ()\r
+               {\r
+                       PermissionSetCollection psc = new PermissionSetCollection ();\r
+                       psc.PermissionSets = new TestList ();\r
                }
 
                [Test]