CryptographicAttributeTest.cs 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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. using NUnit.Framework;
  10. using System;
  11. using System.Collections;
  12. using System.Security.Cryptography;
  13. using System.Security.Cryptography.Pkcs;
  14. namespace MonoTests.System.Security.Cryptography.Pkcs {
  15. [TestFixture]
  16. public class CryptographicAttributeTest {
  17. static string defaultOid = "1.2.840.113549.1.7.1";
  18. static string defaultName = "PKCS 7 Data";
  19. [Test]
  20. public void ConstructorOid ()
  21. {
  22. Oid o = new Oid (defaultOid);
  23. CryptographicAttribute ca = new CryptographicAttribute (o);
  24. Assert.AreEqual (defaultName, ca.Oid.FriendlyName, "Oid.FriendlyName");
  25. Assert.AreEqual (defaultOid, ca.Oid.Value, "Oid.Value");
  26. Assert.AreEqual (0, ca.Values.Count, "Values");
  27. }
  28. [Test]
  29. //BUG [ExpectedException (typeof (ArgumentNullException))]
  30. public void ConstructorOidNull ()
  31. {
  32. CryptographicAttribute ca = new CryptographicAttribute (null);
  33. }
  34. [Test]
  35. public void ConstructorOidArrayList ()
  36. {
  37. Oid o = new Oid (defaultOid);
  38. ArrayList al = new ArrayList ();
  39. CryptographicAttribute ca = new CryptographicAttribute (o, al);
  40. Assert.AreEqual (defaultName, ca.Oid.FriendlyName, "Oid.FriendlyName");
  41. Assert.AreEqual (defaultOid, ca.Oid.Value, "Oid.Value");
  42. Assert.AreEqual (0, ca.Values.Count, "Values");
  43. }
  44. [Test]
  45. //BUG [ExpectedException (typeof (ArgumentNullException))]
  46. public void ConstructorOidNullArrayList ()
  47. {
  48. ArrayList al = new ArrayList ();
  49. CryptographicAttribute ca = new CryptographicAttribute (null, al);
  50. }
  51. [Test]
  52. //BUG [ExpectedException (typeof (ArgumentNullException))]
  53. [ExpectedException (typeof (NullReferenceException))]
  54. public void ConstructorOidArrayListNull ()
  55. {
  56. Oid o = new Oid (defaultOid);
  57. ArrayList al = null; // do not confuse compiler
  58. CryptographicAttribute ca = new CryptographicAttribute (o, al);
  59. }
  60. [Test]
  61. public void ConstructorOidObject ()
  62. {
  63. Oid o = new Oid (defaultOid);
  64. CryptographicAttribute ca = new CryptographicAttribute (o, o);
  65. Assert.AreEqual (defaultName, ca.Oid.FriendlyName, "Oid.FriendlyName");
  66. Assert.AreEqual (defaultOid, ca.Oid.Value, "Oid.Value");
  67. Assert.AreEqual (1, ca.Values.Count, "Values");
  68. }
  69. [Test]
  70. //BUG [ExpectedException (typeof (ArgumentNullException))]
  71. public void ConstructorOidNullObject ()
  72. {
  73. Oid o = new Oid (defaultOid);
  74. CryptographicAttribute ca = new CryptographicAttribute (null, o);
  75. }
  76. [Test]
  77. //BUG [ExpectedException (typeof (ArgumentNullException))]
  78. public void ConstructorOidObjectNull ()
  79. {
  80. Oid o = new Oid (defaultOid);
  81. object obj = null; // do not confuse compiler
  82. CryptographicAttribute ca = new CryptographicAttribute (o, obj);
  83. }
  84. }
  85. }