<commit_before>//
// KeyInfoRetrievalMethodTest.cs - NUnit Test Cases for KeyInfoRetrievalMethod
//
// Author:
//	<NAME>  <<EMAIL>>
//
// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//

using System.Xml;

namespace System.Security.Cryptography.Xml.Tests {

	[TestFixture]
	public class KeyInfoRetrievalMethodTest {

		[Test]
		public void TestNewEmptyKeyNode () 
		{
			KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
			Assert.AreEqual ("<RetrievalMethod xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml), "Empty");
		}

		[Test]
		public void TestNewKeyNode () 
		{
			string uri = "http://www.go-mono.com/";
			KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
			uri1.Uri = uri;
			XmlElement xel = uri1.GetXml ();

			KeyInfoRetrievalMethod uri2 = new KeyInfoRetrievalMethod (uri1.Uri);
			uri2.LoadXml (xel);

			Assert.AreEqual ((uri1.GetXml ().OuterXml), (uri2.GetXml ().OuterXml), "uri1==uri2");
			Assert.AreEqual (uri, uri1.Uri, "uri==Uri");
		}

		[Test]
		public void TestImportKeyNode () 
		{
			string value = "<RetrievalMethod URI=\"http://www.go-mono.com/\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />";
			XmlDocument doc = new XmlDocument ();
			doc.LoadXml (value);

			KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
			uri1.LoadXml (doc.DocumentElement);

			// verify that proper XML is generated (equals to original)
			string s = (uri1.GetXml ().OuterXml);
			Assert.AreEqual (value, s, "Xml");

			// verify that property is parsed correctly
			Assert.AreEqual ("http://www.go-mono.com/", uri1.Uri, "Uri");
		}

		[Test]
		[ExpectedException (typeof (ArgumentNullException))]
		public void InvalidKeyNode1 () 
		{
			KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
			uri1.LoadXml (null);
		}

		[Test]
		public void InvalidKeyNode2 () 
		{
			string bad = "<Test></Test>";
			XmlDocument doc = new XmlDocument ();
			doc.LoadXml (bad);

			KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod ();
			// no exception is thrown
			uri1.LoadXml (doc.DocumentElement);
			AssertCrypto.AssertXmlEquals ("invalid", "<RetrievalMethod xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml ().OuterXml));
		}
	}
}<commit_msg>Convert KeyInfoRetrievalMethodTest<commit_after>//
// KeyInfoRetrievalMethodTest.cs - NUnit Test Cases for KeyInfoRetrievalMethod
//
// Author:
//	<NAME>  <<EMAIL>>
//
// (C) 2002, 2003 Motus Technologies Inc. (http://www.motus.com)
// Copyright (C) 2005 Novell, Inc (http://www.novell.com)
//

using System.Xml;
using Xunit;

namespace System.Security.Cryptography.Xml.Tests
{

    public class KeyInfoRetrievalMethodTest
    {

        [Fact]
        public void TestNewEmptyKeyNode()
        {
            KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod();
            Assert.Equal("<RetrievalMethod xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml().OuterXml));
        }

        [Fact]
        public void TestNewKeyNode()
        {
            string uri = "http://www.go-mono.com/";
            KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod();
            uri1.Uri = uri;
            XmlElement xel = uri1.GetXml();

            KeyInfoRetrievalMethod uri2 = new KeyInfoRetrievalMethod(uri1.Uri);
            uri2.LoadXml(xel);

            Assert.Equal((uri1.GetXml().OuterXml), (uri2.GetXml().OuterXml));
            Assert.Equal(uri, uri1.Uri);
        }

        [Fact]
        public void TestImportKeyNode()
        {
            string value = "<RetrievalMethod URI=\"http://www.go-mono.com/\" xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />";
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(value);

            KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod();
            uri1.LoadXml(doc.DocumentElement);

            // verify that proper XML is generated (equals to original)
            string s = (uri1.GetXml().OuterXml);
            Assert.Equal(value, s);

            // verify that property is parsed correctly
            Assert.Equal("http://www.go-mono.com/", uri1.Uri);
        }

        [Fact]
        public void InvalidKeyNode1()
        {
            KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod();
            Assert.Throws<ArgumentNullException>(() => uri1.LoadXml(null));
        }

        [Fact]
        public void InvalidKeyNode2()
        {
            string bad = "<Test></Test>";
            XmlDocument doc = new XmlDocument();
            doc.LoadXml(bad);

            KeyInfoRetrievalMethod uri1 = new KeyInfoRetrievalMethod();
            // no exception is thrown
            uri1.LoadXml(doc.DocumentElement);
            AssertCrypto.AssertXmlEquals("invalid", "<RetrievalMethod xmlns=\"http://www.w3.org/2000/09/xmldsig#\" />", (uri1.GetXml().OuterXml));
        }
    }
}
{'fraction_non_alphanumeric': 0.14279910623603495, 'fraction_numerical': 0.022750355474304287, 'mean_word_length': 2.674626865671642, 'pattern_counts': {'":': 0, '<': 20, '<?xml version=': 0, '>': 21, 'https://': 0, 'lorem ipsum': 0, 'www.': 16, 'xml': 12}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6745470', 'n_tokens_mistral': 1756, 'n_tokens_neox': 1574, 'n_words': 313}