OidCollectionTest.cs 1.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475
  1. //
  2. // OidCollectionTest.cs - NUnit tests for OidCollection
  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.Security.Cryptography;
  13. namespace MonoTests.System.Security.Cryptography {
  14. [TestFixture]
  15. public class OidCollectionTest : Assertion {
  16. [Test]
  17. public void Constructor ()
  18. {
  19. OidCollection oc = new OidCollection ();
  20. // default properties
  21. AssertEquals ("Count", 0, oc.Count);
  22. Assert ("IsSynchronized", !oc.IsSynchronized);
  23. AssertNotNull ("SyncRoot", oc.SyncRoot);
  24. AssertNotNull ("GetEnumerator", oc.GetEnumerator ());
  25. }
  26. [Test]
  27. public void Add ()
  28. {
  29. OidCollection oc = new OidCollection ();
  30. oc.Add (new Oid ("1.0"));
  31. AssertEquals ("Count", 1, oc.Count);
  32. AssertEquals ("[0]", "1.0", oc [0].Value);
  33. AssertEquals ("['1.0']", "1.0", oc ["1.0"].Value);
  34. }
  35. [Test]
  36. //BUG [ExpectedException (typeof (ArgumentNullException))]
  37. public void AddNull ()
  38. {
  39. OidCollection oc = new OidCollection ();
  40. oc.Add (null);
  41. AssertEquals ("Count", 1, oc.Count);
  42. // AssertNull ("[0]", oc); throw NullReferenceException
  43. }
  44. [Test]
  45. public void CopyToOid ()
  46. {
  47. OidCollection oc = new OidCollection ();
  48. oc.Add (new Oid ("1.0"));
  49. Oid[] array = new Oid [1];
  50. oc.CopyTo (array, 0);
  51. AssertEquals ("CopyTo(Oid)", "1.0", array [0].Value);
  52. }
  53. [Test]
  54. [ExpectedException (typeof (ArgumentNullException))]
  55. public void CopyToOidNull ()
  56. {
  57. OidCollection oc = new OidCollection ();
  58. oc.Add (new Oid ("1.0"));
  59. Oid[] array = null;
  60. oc.CopyTo (array, 0);
  61. }
  62. }
  63. }
  64. #endif