ToXml() public method

public ToXml ( ) : SecurityElement
return SecurityElement
		public void PermissionState_None ()
		{
			SiteIdentityPermission sip = new SiteIdentityPermission (PermissionState.None);
			Assert.AreEqual (String.Empty, sip.Site, "Site");
			SecurityElement se = sip.ToXml ();
			// only class and version are present
			Assert.AreEqual (2, se.Attributes.Count, "Xml-Attributes");
			Assert.IsNull (se.Children, "Xml-Children");
			SiteIdentityPermission copy = (SiteIdentityPermission)sip.Copy ();
			Assert.IsFalse (Object.ReferenceEquals (sip, copy), "ReferenceEquals");
		}
		public void PermissionStateUnrestricted ()
		{
			// In 2.0 Unrestricted are permitted for identity permissions
			SiteIdentityPermission sip = new SiteIdentityPermission (PermissionState.Unrestricted);
			Assert.AreEqual (String.Empty, sip.Site, "Site");
			SecurityElement se = sip.ToXml ();
			Assert.AreEqual (3, se.Attributes.Count, "Xml-Attributes");
			Assert.IsNull (se.Children, "Xml-Children");
			SiteIdentityPermission copy = (SiteIdentityPermission)sip.Copy ();
			Assert.IsFalse (Object.ReferenceEquals (sip, copy), "ReferenceEquals");
			// and they aren't equals to None
			Assert.IsFalse (sip.Equals (new SiteIdentityPermission (PermissionState.None)));
		}
		public void FromXml_NoVersion ()
		{
			SiteIdentityPermission sip = new SiteIdentityPermission (PermissionState.None);
			SecurityElement se = sip.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("class", se.Attribute ("class"));
			sip.FromXml (w);
		}
		public void FromXml_WrongVersion ()
		{
			SiteIdentityPermission sip = new SiteIdentityPermission (PermissionState.None);
			SecurityElement se = sip.ToXml ();
			se.Attributes.Remove ("version");
			se.Attributes.Add ("version", "2");
			sip.FromXml (se);
		}
		public void FromXml_NoClass ()
		{
			SiteIdentityPermission sip = new SiteIdentityPermission (PermissionState.None);
			SecurityElement se = sip.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("version", se.Attribute ("version"));
			sip.FromXml (w);
			// doesn't even care of the class attribute presence
		}
		public void FromXml_WrongClass ()
		{
			SiteIdentityPermission sip = new SiteIdentityPermission (PermissionState.None);
			SecurityElement se = sip.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("class", "Wrong" + se.Attribute ("class"));
			w.AddAttribute ("version", se.Attribute ("version"));
			sip.FromXml (w);
			// doesn't care of the class name at that stage
			// anyway the class has already be created so...
		}
		public void FromXml_WrongTagCase ()
		{
			SiteIdentityPermission sip = new SiteIdentityPermission (PermissionState.None);
			SecurityElement se = sip.ToXml ();
			se.Tag = "IPERMISSION"; // instead of IPermission
			sip.FromXml (se);
		}
		public void FromXml_WrongTag ()
		{
			SiteIdentityPermission sip = new SiteIdentityPermission (PermissionState.None);
			SecurityElement se = sip.ToXml ();
			se.Tag = "IMono";
			sip.FromXml (se);
		}