2009-06-12 Bill Holmes <billholmes54@gmail.com>
[mono.git] / mcs / class / System / Test / System.Security.Cryptography / OidCollectionTest.cs
1 //
2 // OidCollectionTest.cs - NUnit tests for OidCollection
3 //
4 // Author:
5 //      Sebastien Pouliot (spouliot@motus.com)
6 //
7 // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
8 //
9
10 #if NET_2_0
11
12 using NUnit.Framework;
13
14 using System;
15 using System.Security.Cryptography;
16
17 namespace MonoTests.System.Security.Cryptography {
18
19         [TestFixture]
20 #if TARGET_JVM
21         [Ignore ("The class System.Security.Cryptography.OidCollection - is not supported")]
22 #endif
23         public class OidCollectionTest : Assertion {
24 #if !TARGET_JVM
25
26                 [Test]
27                 public void Constructor () 
28                 {
29                         OidCollection oc = new OidCollection ();
30                         // default properties
31                         AssertEquals ("Count", 0, oc.Count);
32                         Assert ("IsSynchronized", !oc.IsSynchronized);
33                         AssertNotNull ("SyncRoot", oc.SyncRoot);
34                         AssertNotNull ("GetEnumerator", oc.GetEnumerator ());
35                 }
36
37                 [Test]
38                 public void Add ()
39                 {
40                         OidCollection oc = new OidCollection ();
41                         oc.Add (new Oid ("1.0"));
42                         AssertEquals ("Count", 1, oc.Count);
43                         AssertEquals ("[0]", "1.0", oc [0].Value);
44                         AssertEquals ("['1.0']", "1.0", oc ["1.0"].Value);
45                 }
46
47                 [Test]
48                 //BUG [ExpectedException (typeof (ArgumentNullException))]
49                 public void AddNull () 
50                 {
51                         OidCollection oc = new OidCollection ();
52                         oc.Add (null);
53                         AssertEquals ("Count", 1, oc.Count);
54                         // AssertNull ("[0]", oc); throw NullReferenceException
55                 }
56
57                 [Test]
58                 public void CopyToOid () 
59                 {
60                         OidCollection oc = new OidCollection ();
61                         oc.Add (new Oid ("1.0"));
62                         Oid[] array = new Oid [1];
63                         oc.CopyTo (array, 0);
64                         AssertEquals ("CopyTo(Oid)", "1.0", array [0].Value);
65                 }
66
67                 [Test]
68                 [ExpectedException (typeof (ArgumentNullException))]
69                 public void CopyToOidNull ()
70                 {
71                         OidCollection oc = new OidCollection ();
72                         oc.Add (new Oid ("1.0"));
73                         Oid[] array = null;
74                         oc.CopyTo (array, 0);
75                 }
76 #endif
77         }
78 }
79
80 #endif