Pkcs9AttributeTest.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // Pkcs9AttributeTest.cs - NUnit tests for Pkcs9Attribute
  3. //
  4. // Author:
  5. // Sebastien Pouliot ([email protected])
  6. //
  7. // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
  8. //
  9. #if NET_1_2
  10. using NUnit.Framework;
  11. using System;
  12. using System.Collections;
  13. using System.Security.Cryptography;
  14. using System.Security.Cryptography.Pkcs;
  15. namespace MonoTests.System.Security.Cryptography.Pkcs {
  16. [TestFixture]
  17. public class Pkcs9AttributeTest : Assertion {
  18. static string defaultOid = "1.2.840.113549.1.7.1";
  19. static string defaultName = "PKCS 7 Data";
  20. [Test]
  21. public void ConstructorOid ()
  22. {
  23. Oid o = new Oid (defaultOid);
  24. Pkcs9Attribute a = new Pkcs9Attribute (o);
  25. AssertEquals ("Oid.FriendlyName", defaultName, a.Oid.FriendlyName);
  26. AssertEquals ("Oid.Value", defaultOid, a.Oid.Value);
  27. AssertEquals ("Values", 0, a.Values.Count);
  28. }
  29. [Test]
  30. //BUG [ExpectedException (typeof (ArgumentNullException))]
  31. public void ConstructorOidNull ()
  32. {
  33. Pkcs9Attribute a = new Pkcs9Attribute (null);
  34. }
  35. [Test]
  36. public void ConstructorOidArrayList ()
  37. {
  38. Oid o = new Oid (defaultOid);
  39. ArrayList al = new ArrayList ();
  40. Pkcs9Attribute a = new Pkcs9Attribute (o, al);
  41. AssertEquals ("Oid.FriendlyName", defaultName, a.Oid.FriendlyName);
  42. AssertEquals ("Oid.Value", defaultOid, a.Oid.Value);
  43. AssertEquals ("Values", 0, a.Values.Count);
  44. }
  45. [Test]
  46. //BUG [ExpectedException (typeof (ArgumentNullException))]
  47. public void ConstructorOidNullArrayList ()
  48. {
  49. ArrayList al = new ArrayList ();
  50. Pkcs9Attribute a = new Pkcs9Attribute (null, al);
  51. }
  52. [Test]
  53. //BUG [ExpectedException (typeof (ArgumentNullException))]
  54. [ExpectedException (typeof (NullReferenceException))]
  55. public void ConstructorOidArrayListNull ()
  56. {
  57. Oid o = new Oid (defaultOid);
  58. ArrayList al = null; // do not confuse compiler
  59. Pkcs9Attribute a = new Pkcs9Attribute (o, al);
  60. }
  61. [Test]
  62. public void ConstructorOidObject ()
  63. {
  64. Oid o = new Oid (defaultOid);
  65. Pkcs9Attribute a = new Pkcs9Attribute (o, o);
  66. AssertEquals ("Oid.FriendlyName", defaultName, a.Oid.FriendlyName);
  67. AssertEquals ("Oid.Value", defaultOid, a.Oid.Value);
  68. AssertEquals ("Values", 1, a.Values.Count);
  69. }
  70. [Test]
  71. //BUG [ExpectedException (typeof (ArgumentNullException))]
  72. public void ConstructorOidNullObject ()
  73. {
  74. Oid o = new Oid (defaultOid);
  75. Pkcs9Attribute a = new Pkcs9Attribute (null, o);
  76. }
  77. [Test]
  78. //BUG [ExpectedException (typeof (ArgumentNullException))]
  79. public void ConstructorOidObjectNull ()
  80. {
  81. Oid o = new Oid (defaultOid);
  82. object obj = null; // do not confuse compiler
  83. Pkcs9Attribute a = new Pkcs9Attribute (o, obj);
  84. }
  85. }
  86. }
  87. #endif