2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / System.Security / Test / System.Security.Cryptography.Xml / KeyInfoNodeTest.cs
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 //
9
10 using System;
11 using System.Security.Cryptography;
12 using System.Security.Cryptography.Xml;
13 using System.Xml;
14
15 using NUnit.Framework;
16
17 namespace MonoTests.System.Security.Cryptography.Xml {
18
19         [TestFixture]
20         public class KeyInfoNodeTest : Assertion {
21
22                 [Test]
23                 public void NewKeyNode () 
24                 {
25                         string test = "<Test></Test>";
26                         XmlDocument doc = new XmlDocument ();
27                         doc.LoadXml (test);
28
29                         KeyInfoNode node1 = new KeyInfoNode ();
30                         node1.Value = doc.DocumentElement;
31                         XmlElement xel = node1.GetXml ();
32
33                         KeyInfoNode node2 = new KeyInfoNode (node1.Value);
34                         node2.LoadXml (xel);
35
36                         AssertEquals ("node1==node2", (node1.GetXml ().OuterXml), (node2.GetXml ().OuterXml));
37                 }
38
39                 [Test]
40                 public void ImportKeyNode () 
41                 {
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);
46
47                         KeyInfoNode node1 = new KeyInfoNode ();
48                         node1.LoadXml (doc.DocumentElement);
49
50                         string s = (node1.GetXml ().OuterXml);
51                         AssertEquals ("Node", value, s);
52                 }
53
54                 // well there's no invalid value - unless you read the doc ;-)
55                 [Test]
56                 public void InvalidKeyNode () 
57                 {
58                         string bad = "<Test></Test>";
59                         XmlDocument doc = new XmlDocument ();
60                         doc.LoadXml (bad);
61
62                         KeyInfoNode node1 = new KeyInfoNode ();
63                         // LAMESPEC: No ArgumentNullException is thrown if value == null
64                         node1.LoadXml (null);
65                         AssertNull ("Value==null", node1.Value);
66                 }
67         }
68 }