(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.Security / Test / System.Security.Cryptography / OidTest.cs
blobd9d35826206f8ca220c6c65aef02e2de3e24c350
1 //
2 // OidTest.cs - NUnit tests for Oid
3 //
4 // Author:
5 // Sebastien Pouliot <sebastien@ximian.com>
6 //
7 // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
8 // Copyright (C) 2004 Novell, Inc (http://www.novell.com)
9 //
10 // Permission is hereby granted, free of charge, to any person obtaining
11 // a copy of this software and associated documentation files (the
12 // "Software"), to deal in the Software without restriction, including
13 // without limitation the rights to use, copy, modify, merge, publish,
14 // distribute, sublicense, and/or sell copies of the Software, and to
15 // permit persons to whom the Software is furnished to do so, subject to
16 // the following conditions:
17 //
18 // The above copyright notice and this permission notice shall be
19 // included in all copies or substantial portions of the Software.
20 //
21 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
22 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
23 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
24 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
25 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
26 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
27 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
30 #if NET_2_0
32 using NUnit.Framework;
34 using System;
35 using System.Security.Cryptography;
37 namespace MonoTests.System.Security.Cryptography {
39 [TestFixture]
40 public class OidTest {
42 static string invalidOid = "1.0";
43 static string invalidName = "friendlyName";
44 static string validOid = "1.2.840.113549.1.1.1";
45 static string validName = "RSA";
47 [Test]
48 public void ConstructorEmpty ()
50 Oid o = new Oid ();
51 Assert.IsNull (o.FriendlyName, "FriendlyName");
52 Assert.IsNull (o.Value, "Value");
55 [Test]
56 public void ConstructorValidString ()
58 Oid o = new Oid (validOid);
59 Assert.AreEqual (validName, o.FriendlyName, "FriendlyName");
60 Assert.AreEqual (validOid, o.Value, "Value");
63 [Test]
64 public void ConstructorInvalidString ()
66 Oid o = new Oid (invalidOid);
67 Assert.IsNull (o.FriendlyName, "FriendlyName");
68 Assert.AreEqual (invalidOid, o.Value, "Value");
71 [Test]
72 [ExpectedException (typeof (ArgumentNullException))]
73 public void ConstructorNullString ()
75 string oid = null; // do not confuse compiler
76 Oid o = new Oid (oid);
79 [Test]
80 public void ConstructorStringString ()
82 Oid o = new Oid (validOid, invalidName);
83 Assert.AreEqual (invalidName, o.FriendlyName, "FriendlyName");
84 Assert.AreEqual (validOid, o.Value, "Value");
87 [Test]
88 //BUG [ExpectedException (typeof (ArgumentNullException))]
89 public void ConstructorStringNullString ()
91 Oid o = new Oid (null, validName);
92 Assert.AreEqual (validName, o.FriendlyName, "FriendlyName");
93 Assert.IsNull (o.Value, "Value");
96 [Test]
97 public void ConstructorStringStringNull ()
99 Oid o = new Oid (validOid, null);
100 Assert.IsNull (o.FriendlyName, "FriendlyName");
101 Assert.AreEqual (validOid, o.Value, "Value");
104 [Test]
105 public void ConstructorOid ()
107 Oid o = new Oid (validOid, invalidName);
108 Oid o2 = new Oid (o);
109 Assert.AreEqual (invalidName, o.FriendlyName, "FriendlyName==invalid");
110 Assert.AreEqual (o.FriendlyName, o2.FriendlyName, "FriendlyName");
111 Assert.AreEqual (o.Value, o2.Value, "Value");
114 [Test]
115 [ExpectedException (typeof (ArgumentNullException))]
116 public void ConstructorOidNull ()
118 Oid onull = null; // do not confuse compiler
119 Oid o = new Oid (onull);
122 [Test]
123 public void FriendlyName ()
125 Oid o = new Oid (invalidOid, invalidName);
126 Assert.AreEqual (invalidName, o.FriendlyName, "FriendlyName-1");
127 Assert.AreEqual (invalidOid, o.Value, "Value-1");
128 o.FriendlyName = validName;
129 Assert.AreEqual (validName, o.FriendlyName, "FriendlyName-2");
130 Assert.AreEqual (validOid, o.Value, "Value-2"); // surprise!
133 [Test]
134 public void FriendlyNameNull ()
136 Oid o = new Oid (validOid, invalidName);
137 Assert.AreEqual (invalidName, o.FriendlyName, "FriendlyName");
138 o.FriendlyName = null;
139 Assert.IsNull (o.FriendlyName, "FriendlyName-Null");
142 [Test]
143 public void Value ()
145 Oid o = new Oid (validOid, invalidName);
146 Assert.AreEqual (validOid, o.Value, "Value-1");
147 o.Value = invalidName;
148 Assert.AreEqual (invalidName, o.Value, "Value-2");
151 [Test]
152 public void ValueNull ()
154 Oid o = new Oid (validOid, invalidName);
155 Assert.AreEqual (validOid, o.Value, "Value");
156 o.Value = null;
157 Assert.IsNull (o.Value, "Value-Null");
160 [Test]
161 public void WellKnownOid ()
163 Oid o = new Oid ("1.2.840.113549.1.1.1");
164 Assert.AreEqual ("1.2.840.113549.1.1.1", o.Value, "RSA Value");
165 Assert.AreEqual ("RSA", o.FriendlyName, "RSA FriendlyName");
167 o = new Oid ("1.2.840.113549.1.7.1");
168 Assert.AreEqual ("1.2.840.113549.1.7.1", o.Value, "PKCS 7 Data Value");
169 Assert.AreEqual ("PKCS 7 Data", o.FriendlyName, "PKCS 7 Data FriendlyName");
171 o = new Oid ("1.2.840.113549.1.9.5");
172 Assert.AreEqual ("1.2.840.113549.1.9.5", o.Value, "Signing Time Value");
173 Assert.AreEqual ("Signing Time", o.FriendlyName, "Signing Time FriendlyName");
175 o = new Oid ("1.2.840.113549.3.7");
176 Assert.AreEqual ("1.2.840.113549.3.7", o.Value, "3des Value");
177 Assert.AreEqual ("3des", o.FriendlyName, "3des FriendlyName");
179 // TODO: add other well known oid as we find them
184 #endif