ToXml() public method

public ToXml ( ) : SecurityElement
return SecurityElement
Exemplo n.º 1
0
		public void ToXml_PolicyLevel () 
		{
			UrlMembershipCondition umc = new UrlMembershipCondition ("http://www.go-mono.com");
			SecurityElement se = umc.ToXml ();
			string s = umc.ToXml ().ToString ();
			// is it accepted for all policy levels ?
			IEnumerator e = SecurityManager.PolicyHierarchy ();
			while (e.MoveNext ()) {
				PolicyLevel pl = e.Current as PolicyLevel;
				UrlMembershipCondition spl = new UrlMembershipCondition ("*");
				spl.FromXml (se, pl);
				Assert.AreEqual (s, spl.ToXml (pl).ToString (), "ToXml(PolicyLevel='" + pl.Label + "')");
			}
			// yes!
		}
Exemplo n.º 2
0
		public void ToFromXmlRoundTrip () 
		{
			UrlMembershipCondition umc1 = new UrlMembershipCondition ("http://www.go-mono.com");
			SecurityElement se = umc1.ToXml ();

			UrlMembershipCondition umc2 = new UrlMembershipCondition ("*");
			umc2.FromXml (se);

			Assert.AreEqual (umc1.GetHashCode (), umc2.GetHashCode (), "ToFromXmlRoundTrip");
		}
Exemplo n.º 3
0
		public void ToXml_Null () 
		{
			UrlMembershipCondition umc = new UrlMembershipCondition ("http://www.go-mono.com");
			// no ArgumentNullException here
			SecurityElement se = umc.ToXml (null);
			Assert.IsNotNull (se, "ToXml(null)");
		}
Exemplo n.º 4
0
		public void FromXml_NoVersion ()
		{
			UrlMembershipCondition umc = new UrlMembershipCondition ("http://www.go-mono.com");
			SecurityElement se = umc.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("class", se.Attribute ("class"));
			umc.FromXml (w);
		}
Exemplo n.º 5
0
		public void FromXml_NoClass ()
		{
			UrlMembershipCondition umc = new UrlMembershipCondition ("http://www.go-mono.com");
			SecurityElement se = umc.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("version", se.Attribute ("version"));
			umc.FromXml (w);
			// doesn't even care of the class attribute presence
		}
Exemplo n.º 6
0
		public void FromXml_InvalidClass ()
		{
			UrlMembershipCondition umc = new UrlMembershipCondition ("http://www.go-mono.com");
			SecurityElement se = umc.ToXml ();
			se.Attributes ["class"] = "Hello world";
			umc.FromXml (se);
		}
Exemplo n.º 7
0
		public void FromXml_InvalidTag () 
		{
			UrlMembershipCondition umc = new UrlMembershipCondition ("http://www.go-mono.com");
			SecurityElement se = umc.ToXml ();
			se.Tag = "IMonoship";
			umc.FromXml (se);
		}