2 // KeyInfoRetrievalMethodTest.cs - NUnit Test Cases for KeyInfoRetrievalMethod
5 // Sebastien Pouliot (spouliot@motus.com)
7 // (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
11 using System.Security.Cryptography;
12 using System.Security.Cryptography.Xml;
15 using NUnit.Framework;
17 namespace MonoTests.System.Security.Cryptography.Xml {
20 public class KeyInfoRetrievalMethodTest {
23 public void TestNewEmptyKeyNode ()
25 KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
26 Assertion.AssertEquals ("Empty", "<RetrievalElement xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml));
30 public void TestNewKeyNode ()
32 string uri = "http://www.go-mono.com/";
33 KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
35 XmlElement xel = uri1.GetXml ();
37 KeyInfoRetrievalMethod uri2 = new KeyInfoRetrievalMethod (uri1.Uri);
40 Assertion.AssertEquals ("uri1==uri2", (uri1.GetXml ().OuterXml), (uri2.GetXml ().OuterXml));
41 Assertion.AssertEquals ("uri==Uri", uri, uri1.Uri);
45 public void TestImportKeyNode ()
47 string value = "<RetrievalElement URI=\"http://www.go-mono.com/\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />";
48 XmlDocument doc = new XmlDocument ();
51 KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
52 uri1.LoadXml (doc.DocumentElement);
54 // verify that proper XML is generated (equals to original)
55 string s = (uri1.GetXml ().OuterXml);
56 Assertion.AssertEquals ("Xml", value, s);
58 // verify that property is parsed correctly
59 Assertion.AssertEquals ("Uri", "http://www.go-mono.com/", uri1.Uri);
63 [ExpectedException (typeof (ArgumentNullException))]
64 public void InvalidKeyNode1 ()
66 KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
71 public void InvalidKeyNode2 ()
73 string bad = "<Test></Test>";
74 XmlDocument doc = new XmlDocument ();
77 KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
78 // no exception is thrown
79 uri1.LoadXml (doc.DocumentElement);
80 // note that URI="" is present (unlike a empty Uri)
81 Assertion.AssertEquals("invalid", "<RetrievalElement URI=\"\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml));