2 // KeyInfoRetrievalMethodTest.cs - NUnit Test Cases for KeyInfoRetrievalMethod
5 // Sebastien Pouliot <sebastien@ximian.com>
7 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
8 // Copyright (C) 2005 Novell, Inc (http://www.novell.com)
12 using System.Security.Cryptography;
13 using System.Security.Cryptography.Xml;
16 using NUnit.Framework;
18 namespace MonoTests.System.Security.Cryptography.Xml {
21 public class KeyInfoRetrievalMethodTest {
24 public void TestNewEmptyKeyNode ()
26 KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
27 Assert.AreEqual ("<RetrievalMethod xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml), "Empty");
31 public void TestNewKeyNode ()
33 string uri = "http://www.go-mono.com/";
34 KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
36 XmlElement xel = uri1.GetXml ();
38 KeyInfoRetrievalMethod uri2 = new KeyInfoRetrievalMethod (uri1.Uri);
41 Assert.AreEqual ((uri1.GetXml ().OuterXml), (uri2.GetXml ().OuterXml), "uri1==uri2");
42 Assert.AreEqual (uri, uri1.Uri, "uri==Uri");
46 public void TestImportKeyNode ()
48 string value = "<RetrievalMethod URI=\"http://www.go-mono.com/\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />";
49 XmlDocument doc = new XmlDocument ();
52 KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
53 uri1.LoadXml (doc.DocumentElement);
55 // verify that proper XML is generated (equals to original)
56 string s = (uri1.GetXml ().OuterXml);
57 Assert.AreEqual (value, s, "Xml");
59 // verify that property is parsed correctly
60 Assert.AreEqual ("http://www.go-mono.com/", uri1.Uri, "Uri");
64 [ExpectedException (typeof (ArgumentNullException))]
65 public void InvalidKeyNode1 ()
67 KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
72 public void InvalidKeyNode2 ()
74 string bad = "<Test></Test>";
75 XmlDocument doc = new XmlDocument ();
78 KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
79 // no exception is thrown
80 uri1.LoadXml (doc.DocumentElement);
81 AssertCrypto.AssertXmlEquals ("invalid", "<RetrievalMethod xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml));