KeyInfoNodeTest.cs 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  1. //
  2. // KeyInfoNodeTest.cs - NUnit Test Cases for KeyInfoNode
  3. //
  4. // Author:
  5. // Sebastien Pouliot ([email protected])
  6. //
  7. // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
  8. //
  9. #if !MOBILE
  10. using System;
  11. using System.Security.Cryptography;
  12. using System.Security.Cryptography.Xml;
  13. using System.Xml;
  14. using NUnit.Framework;
  15. namespace MonoTests.System.Security.Cryptography.Xml {
  16. [TestFixture]
  17. public class KeyInfoNodeTest {
  18. [Test]
  19. public void NewKeyNode ()
  20. {
  21. string test = "<Test></Test>";
  22. XmlDocument doc = new XmlDocument ();
  23. doc.LoadXml (test);
  24. KeyInfoNode node1 = new KeyInfoNode ();
  25. node1.Value = doc.DocumentElement;
  26. XmlElement xel = node1.GetXml ();
  27. KeyInfoNode node2 = new KeyInfoNode (node1.Value);
  28. node2.LoadXml (xel);
  29. Assert.AreEqual ((node1.GetXml ().OuterXml), (node2.GetXml ().OuterXml), "node1==node2");
  30. }
  31. [Test]
  32. public void ImportKeyNode ()
  33. {
  34. // Note: KeyValue is a valid KeyNode
  35. string value = "<KeyName xmlns=\"http://www.w3.org/2000/09/xmldsig#\">Mono::</KeyName>";
  36. XmlDocument doc = new XmlDocument ();
  37. doc.LoadXml (value);
  38. KeyInfoNode node1 = new KeyInfoNode ();
  39. node1.LoadXml (doc.DocumentElement);
  40. string s = (node1.GetXml ().OuterXml);
  41. Assert.AreEqual (value, s, "Node");
  42. }
  43. // well there's no invalid value - unless you read the doc ;-)
  44. [Test]
  45. public void InvalidKeyNode ()
  46. {
  47. string bad = "<Test></Test>";
  48. XmlDocument doc = new XmlDocument ();
  49. doc.LoadXml (bad);
  50. KeyInfoNode node1 = new KeyInfoNode ();
  51. // LAMESPEC: No ArgumentNullException is thrown if value == null
  52. node1.LoadXml (null);
  53. Assert.IsNull (node1.Value, "Value==null");
  54. }
  55. }
  56. }
  57. #endif