2009-06-26 Robert Jordan <robertj@gmx.net>
[mono.git] / mcs / class / System.Security / Test / System.Security.Cryptography.Pkcs / CryptographicAttributeTest.cs
1 //
2 // CryptographicAttributeTest.cs - NUnit tests for CryptographicAttribute
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.Collections;
16 using System.Security.Cryptography;
17 using System.Security.Cryptography.Pkcs;
18
19 namespace MonoTests.System.Security.Cryptography.Pkcs {
20
21         [TestFixture]
22         public class CryptographicAttributeTest {
23
24                 static string defaultOid = "1.2.840.113549.1.7.1";
25                 static string defaultName = "PKCS 7 Data";
26
27                 [Test]
28                 public void ConstructorOid () 
29                 {
30                         Oid o = new Oid (defaultOid);
31                         CryptographicAttribute ca = new CryptographicAttribute (o);
32                         Assert.AreEqual (defaultName, ca.Oid.FriendlyName, "Oid.FriendlyName");
33                         Assert.AreEqual (defaultOid, ca.Oid.Value, "Oid.Value");
34                         Assert.AreEqual (0, ca.Values.Count, "Values");
35                 }
36
37                 [Test]
38                 //BUG [ExpectedException (typeof (ArgumentNullException))]
39                 public void ConstructorOidNull () 
40                 {
41                         CryptographicAttribute ca = new CryptographicAttribute (null);
42                 }
43
44                 [Test]
45                 public void ConstructorOidArrayList () 
46                 {
47                         Oid o = new Oid (defaultOid);
48                         ArrayList al = new ArrayList ();
49                         CryptographicAttribute ca = new CryptographicAttribute (o, al);
50                         Assert.AreEqual (defaultName, ca.Oid.FriendlyName, "Oid.FriendlyName");
51                         Assert.AreEqual (defaultOid, ca.Oid.Value, "Oid.Value");
52                         Assert.AreEqual (0, ca.Values.Count, "Values");
53                 }
54
55                 [Test]
56                 //BUG [ExpectedException (typeof (ArgumentNullException))]
57                 public void ConstructorOidNullArrayList () 
58                 {
59                         ArrayList al = new ArrayList ();
60                         CryptographicAttribute ca = new CryptographicAttribute (null, al);
61                 }
62
63                 [Test]
64                 //BUG [ExpectedException (typeof (ArgumentNullException))]
65                 [ExpectedException (typeof (NullReferenceException))]
66                 public void ConstructorOidArrayListNull () 
67                 {
68                         Oid o = new Oid (defaultOid);
69                         ArrayList al = null; // do not confuse compiler
70                         CryptographicAttribute ca = new CryptographicAttribute (o, al);
71                 }
72
73                 [Test]
74                 public void ConstructorOidObject () 
75                 {
76                         Oid o = new Oid (defaultOid);
77                         CryptographicAttribute ca = new CryptographicAttribute (o, o);
78                         Assert.AreEqual (defaultName, ca.Oid.FriendlyName, "Oid.FriendlyName");
79                         Assert.AreEqual (defaultOid, ca.Oid.Value, "Oid.Value");
80                         Assert.AreEqual (1, ca.Values.Count, "Values");
81                 }
82
83                 [Test]
84                 //BUG [ExpectedException (typeof (ArgumentNullException))]
85                 public void ConstructorOidNullObject () 
86                 {
87                         Oid o = new Oid (defaultOid);
88                         CryptographicAttribute ca = new CryptographicAttribute (null, o);
89                 }
90
91                 [Test]
92                 //BUG [ExpectedException (typeof (ArgumentNullException))]
93                 public void ConstructorOidObjectNull () 
94                 {
95                         Oid o = new Oid (defaultOid);
96                         object obj = null; // do not confuse compiler
97                         CryptographicAttribute ca = new CryptographicAttribute (o, obj);
98                 }
99         }
100 }
101
102 #endif