CryptographicAttributeTest.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  1. //
  2. // CryptographicAttributeTest.cs - NUnit tests for CryptographicAttribute
  3. //
  4. // Author:
  5. // Sebastien Pouliot ([email protected])
  6. //
  7. // (C) 2003 Motus Technologies Inc. (http://www.motus.com)
  8. //
  9. #if NET_2_0
  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 CryptographicAttributeTest {
  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. CryptographicAttribute ca = new CryptographicAttribute (o);
  25. Assert.AreEqual (defaultName, ca.Oid.FriendlyName, "Oid.FriendlyName");
  26. Assert.AreEqual (defaultOid, ca.Oid.Value, "Oid.Value");
  27. Assert.AreEqual (0, ca.Values.Count, "Values");
  28. }
  29. [Test]
  30. //BUG [ExpectedException (typeof (ArgumentNullException))]
  31. public void ConstructorOidNull ()
  32. {
  33. CryptographicAttribute ca = new CryptographicAttribute (null);
  34. }
  35. [Test]
  36. public void ConstructorOidArrayList ()
  37. {
  38. Oid o = new Oid (defaultOid);
  39. ArrayList al = new ArrayList ();
  40. CryptographicAttribute ca = new CryptographicAttribute (o, al);
  41. Assert.AreEqual (defaultName, ca.Oid.FriendlyName, "Oid.FriendlyName");
  42. Assert.AreEqual (defaultOid, ca.Oid.Value, "Oid.Value");
  43. Assert.AreEqual (0, ca.Values.Count, "Values");
  44. }
  45. [Test]
  46. //BUG [ExpectedException (typeof (ArgumentNullException))]
  47. public void ConstructorOidNullArrayList ()
  48. {
  49. ArrayList al = new ArrayList ();
  50. CryptographicAttribute ca = new CryptographicAttribute (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. CryptographicAttribute ca = new CryptographicAttribute (o, al);
  60. }
  61. [Test]
  62. public void ConstructorOidObject ()
  63. {
  64. Oid o = new Oid (defaultOid);
  65. CryptographicAttribute ca = new CryptographicAttribute (o, o);
  66. Assert.AreEqual (defaultName, ca.Oid.FriendlyName, "Oid.FriendlyName");
  67. Assert.AreEqual (defaultOid, ca.Oid.Value, "Oid.Value");
  68. Assert.AreEqual (1, ca.Values.Count, "Values");
  69. }
  70. [Test]
  71. //BUG [ExpectedException (typeof (ArgumentNullException))]
  72. public void ConstructorOidNullObject ()
  73. {
  74. Oid o = new Oid (defaultOid);
  75. CryptographicAttribute ca = new CryptographicAttribute (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. CryptographicAttribute ca = new CryptographicAttribute (o, obj);
  84. }
  85. }
  86. }
  87. #endif