ToXml() public method

public ToXml ( ) : SecurityElement
return SecurityElement
		public void ToXml_PolicyLevel ()
		{
			ZoneMembershipCondition zmc = new ZoneMembershipCondition (SecurityZone.MyComputer);
			SecurityElement se = zmc.ToXml ();
			string s = zmc.ToXml ().ToString ();
			// is it accepted for all policy levels ?
			IEnumerator e = SecurityManager.PolicyHierarchy ();
			while (e.MoveNext ()) {
				PolicyLevel pl = e.Current as PolicyLevel;
				ZoneMembershipCondition spl = new ZoneMembershipCondition (SecurityZone.Internet);
				spl.FromXml (se, pl);
				Assert.AreEqual (s, spl.ToXml (pl).ToString (), "ToXml(PolicyLevel='" + pl.Label + "')");
			}
			// yes!
		}
		private ZoneMembershipCondition BasicTest (SecurityZone zone)
		{
			ZoneMembershipCondition zmc = new ZoneMembershipCondition (zone);
			Assert.AreEqual (zone, zmc.SecurityZone, "SecurityZone");
			Assert.IsFalse (zmc.Check (null), "Check(null)");
			Assert.IsFalse (zmc.Check (allEmpty), "Check(empty)");
			Assert.IsFalse (zmc.Check (hostOther), "Check(hostOther)");
			Assert.IsFalse (zmc.Check (assemblyOther), "Check(assemblyOther)");

			ZoneMembershipCondition copy = (ZoneMembershipCondition) zmc.Copy ();
			Assert.IsTrue (zmc.Equals (copy), "Equals-1");
			Assert.IsTrue (copy.Equals (zmc), "Equals-2");
			Assert.IsFalse (Object.ReferenceEquals (zmc, copy), "!ReferenceEquals");
			Assert.IsFalse (zmc.Equals (null), "Equals-3");
			Assert.IsFalse (zmc.Equals (wrongEvidence), "Equals-4");

			SecurityElement se = zmc.ToXml ();
			copy.FromXml (se);
			Assert.IsTrue (zmc.Equals (copy), "Equals-5");
			Assert.AreEqual (se.ToString (), zmc.ToXml (null).ToString (), "Equals-6");

			Assert.IsTrue (zmc.ToString ().StartsWith ("Zone - "), "ToString-1");
			Assert.IsTrue (zmc.ToString ().EndsWith (zmc.SecurityZone.ToString ()), "ToString-2");

			Assert.AreEqual (zmc.SecurityZone.GetHashCode (), zmc.GetHashCode (), "GetHashCode");

			return zmc; // for further tests
		}
		public void ToXml_Null ()
		{
			ZoneMembershipCondition zmc = new ZoneMembershipCondition (SecurityZone.MyComputer);
			// no ArgumentNullException here
			SecurityElement se = zmc.ToXml (null);
			Assert.IsNotNull (se, "ToXml(null)");
		}
		public void FromXml_NoVersion ()
		{
			ZoneMembershipCondition zmc = new ZoneMembershipCondition (SecurityZone.MyComputer);
			SecurityElement se = zmc.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("class", se.Attribute ("class"));
			zmc.FromXml (w);
		}
		public void FromXml_NoClass ()
		{
			ZoneMembershipCondition zmc = new ZoneMembershipCondition (SecurityZone.MyComputer);
			SecurityElement se = zmc.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("version", se.Attribute ("version"));
			zmc.FromXml (w);
			// doesn't even care of the class attribute presence
		}
		public void FromXml_InvalidClass ()
		{
			ZoneMembershipCondition zmc = new ZoneMembershipCondition (SecurityZone.MyComputer);
			SecurityElement se = zmc.ToXml ();
			se.Attributes ["class"] = "Hello world";
			zmc.FromXml (se);
		}
		public void FromXml_InvalidTag ()
		{
			ZoneMembershipCondition zmc = new ZoneMembershipCondition (SecurityZone.MyComputer);
			SecurityElement se = zmc.ToXml ();
			se.Tag = "IMonoship";
			zmc.FromXml (se);
		}