KeyInfoNodeTest.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  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. using System;
  10. using System.Security.Cryptography;
  11. using System.Security.Cryptography.Xml;
  12. using System.Xml;
  13. using NUnit.Framework;
  14. namespace MonoTests.System.Security.Cryptography.Xml {
  15. [TestFixture]
  16. public class KeyInfoNodeTest : Assertion {
  17. [Test]
  18. public void NewKeyNode ()
  19. {
  20. string test = "<Test></Test>";
  21. XmlDocument doc = new XmlDocument ();
  22. doc.LoadXml (test);
  23. KeyInfoNode node1 = new KeyInfoNode ();
  24. node1.Value = doc.DocumentElement;
  25. XmlElement xel = node1.GetXml ();
  26. KeyInfoNode node2 = new KeyInfoNode (node1.Value);
  27. node2.LoadXml (xel);
  28. AssertEquals ("node1==node2", (node1.GetXml ().OuterXml), (node2.GetXml ().OuterXml));
  29. }
  30. [Test]
  31. public void ImportKeyNode ()
  32. {
  33. // Note: KeyValue is a valid KeyNode
  34. string value = "<KeyName xmlns=\"http://www.w3.org/2000/09/xmldsig#\">Mono::</KeyName>";
  35. XmlDocument doc = new XmlDocument ();
  36. doc.LoadXml (value);
  37. KeyInfoNode node1 = new KeyInfoNode ();
  38. node1.LoadXml (doc.DocumentElement);
  39. string s = (node1.GetXml ().OuterXml);
  40. AssertEquals ("Node", value, s);
  41. }
  42. // well there's no invalid value - unless you read the doc ;-)
  43. [Test]
  44. public void InvalidKeyNode ()
  45. {
  46. string bad = "<Test></Test>";
  47. XmlDocument doc = new XmlDocument ();
  48. doc.LoadXml (bad);
  49. KeyInfoNode node1 = new KeyInfoNode ();
  50. // LAMESPEC: No ArgumentNullException is thrown if value == null
  51. node1.LoadXml (null);
  52. AssertNull ("Value==null", node1.Value);
  53. }
  54. }
  55. }