2009-07-11 Michael Barker <mike@middlesoft.co.uk>
[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 {
24 #if !TARGET_JVM
25
26                 [Test]
27                 public void Constructor () 
28                 {
29                         OidCollection oc = new OidCollection ();
30                         // default properties
31                         Assert.AreEqual (0, oc.Count, "Count");
32                         Assert.IsTrue (!oc.IsSynchronized, "IsSynchronized");
33                         Assert.IsNotNull (oc.SyncRoot, "SyncRoot");
34                         Assert.IsNotNull (oc.GetEnumerator (), "GetEnumerator");
35                 }
36
37                 [Test]
38                 public void Add ()
39                 {
40                         OidCollection oc = new OidCollection ();
41                         oc.Add (new Oid ("1.0"));
42                         Assert.AreEqual (1, oc.Count, "Count");
43                         Assert.AreEqual ("1.0", oc [0].Value, "[0]");
44                         Assert.AreEqual ("1.0", oc ["1.0"].Value, "['1.0']");
45                 }
46
47                 [Test]
48                 //BUG [ExpectedException (typeof (ArgumentNullException))]
49                 public void AddNull () 
50                 {
51                         OidCollection oc = new OidCollection ();
52                         oc.Add (null);
53                         Assert.AreEqual (1, oc.Count, "Count");
54                         // Assert.IsNull (oc, "[0]"); 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                         Assert.AreEqual ("1.0", array [0].Value, "CopyTo(Oid)");
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