**** Merged from MCS ****
[mono-project.git] / mcs / class / System.Security / Test / System.Security.Cryptography.Xml / KeyInfoNodeTest.cs
blob5f27cf1fd2c92ff15074fb3441ace5d7f1760e5c
1 //
2 // KeyInfoNodeTest.cs - NUnit Test Cases for KeyInfoNode
3 //
4 // Author:
5 // Sebastien Pouliot (spouliot@motus.com)
6 //
7 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
8 //
10 using System;
11 using System.Security.Cryptography;
12 using System.Security.Cryptography.Xml;
13 using System.Xml;
15 using NUnit.Framework;
17 namespace MonoTests.System.Security.Cryptography.Xml {
19 [TestFixture]
20 public class KeyInfoNodeTest : Assertion {
22 [Test]
23 public void NewKeyNode ()
25 string test = "<Test></Test>";
26 XmlDocument doc = new XmlDocument ();
27 doc.LoadXml (test);
29 KeyInfoNode node1 = new KeyInfoNode ();
30 node1.Value = doc.DocumentElement;
31 XmlElement xel = node1.GetXml ();
33 KeyInfoNode node2 = new KeyInfoNode (node1.Value);
34 node2.LoadXml (xel);
36 AssertEquals ("node1==node2", (node1.GetXml ().OuterXml), (node2.GetXml ().OuterXml));
39 [Test]
40 public void ImportKeyNode ()
42 // Note: KeyValue is a valid KeyNode
43 string value = "<KeyName xmlns=\"http://www.w3.org/2000/09/xmldsig#\">Mono::</KeyName>";
44 XmlDocument doc = new XmlDocument ();
45 doc.LoadXml (value);
47 KeyInfoNode node1 = new KeyInfoNode ();
48 node1.LoadXml (doc.DocumentElement);
50 string s = (node1.GetXml ().OuterXml);
51 AssertEquals ("Node", value, s);
54 // well there's no invalid value - unless you read the doc ;-)
55 [Test]
56 public void InvalidKeyNode ()
58 string bad = "<Test></Test>";
59 XmlDocument doc = new XmlDocument ();
60 doc.LoadXml (bad);
62 KeyInfoNode node1 = new KeyInfoNode ();
63 // LAMESPEC: No ArgumentNullException is thrown if value == null
64 node1.LoadXml (null);
65 AssertNull ("Value==null", node1.Value);