ToXml() public method

public ToXml ( ) : SecurityElement
return System.Security.SecurityElement
Exemplo n.º 1
0
 public static void AllMembershipConditionCallMethods()
 {
     AllMembershipCondition amc = new AllMembershipCondition();
     bool check = amc.Check(new Evidence());
     IMembershipCondition imc = amc.Copy();
     check = amc.Equals(new object());
     int hash = amc.GetHashCode();
     string str = amc.ToString();
     SecurityElement se = new SecurityElement("");
     PolicyLevel pl = (PolicyLevel)Activator.CreateInstance(typeof(PolicyLevel), true);
     amc.FromXml(se);
     amc.FromXml(se, pl);
     se = amc.ToXml();
     se = amc.ToXml(pl);
 }
		public void FromXml ()
		{
			AllMembershipCondition all = new AllMembershipCondition ();
			SecurityElement se = all.ToXml ();
			all.FromXml (se);
		}
		public void ToXml ()
		{
			AllMembershipCondition all = new AllMembershipCondition ();
			SecurityElement se = all.ToXml ();
			Assert.AreEqual ("IMembershipCondition", se.Tag, "Tag");
			Assert.IsTrue (se.Attribute ("class").StartsWith ("System.Security.Policy.AllMembershipCondition"), "class");
			Assert.AreEqual ("1", se.Attribute ("version"), "version");
			Assert.AreEqual (se.ToString (), all.ToXml (null).ToString (), "ToXml(null)");
			Assert.AreEqual (se.ToString (), all.ToXml (PolicyLevel.CreateAppDomainLevel ()).ToString (), "ToXml(PolicyLevel)");
		}
		public void FromXml_PolicyLevelNull ()
		{
			AllMembershipCondition all = new AllMembershipCondition ();
			SecurityElement se = all.ToXml ();
			all.FromXml (se, null);
		}
		public void FromXml_NoVersion ()
		{
			AllMembershipCondition all = new AllMembershipCondition ();
			SecurityElement se = all.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("class", se.Attribute ("class"));
			all.FromXml (w);
		}
		public void FromXml_InvalidVersion ()
		{
			AllMembershipCondition all = new AllMembershipCondition ();
			SecurityElement se = all.ToXml ();

			SecurityElement w = new SecurityElement (se.Tag);
			w.AddAttribute ("class", se.Attribute ("class"));
			w.AddAttribute ("version", "2");
			all.FromXml (w);
			// doesn't seems to care about the version number!
		}
		public void FromXml_NoClass ()
		{
			AllMembershipCondition all = new AllMembershipCondition ();
			SecurityElement se = all.ToXml ();

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