예제 #1
0
		public void FromXml_InvalidClass ()
		{
			ZoneMembershipCondition zmc = new ZoneMembershipCondition (SecurityZone.MyComputer);
			SecurityElement se = zmc.ToXml ();
			se.Attributes ["class"] = "Hello world";
			zmc.FromXml (se);
		}
예제 #2
0
        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");

#if NET_2_0
            Assert.AreEqual(zmc.SecurityZone.GetHashCode(), zmc.GetHashCode(), "GetHashCode");
#endif

            return(zmc);            // for further tests
        }
예제 #3
0
		public void FromXml_InvalidTag ()
		{
			ZoneMembershipCondition zmc = new ZoneMembershipCondition (SecurityZone.MyComputer);
			SecurityElement se = zmc.ToXml ();
			se.Tag = "IMonoship";
			zmc.FromXml (se);
		}
예제 #4
0
		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);
		}
예제 #5
0
		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
		}
예제 #6
0
		public void FromXml_PolicyLevel ()
		{
			ZoneMembershipCondition zmc = new ZoneMembershipCondition (SecurityZone.MyComputer);
			SecurityElement se = zmc.ToXml ();
			// 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.IsTrue (spl.Equals (zmc), "FromXml(PolicyLevel='" + pl.Label + "')");
			}
			// yes!
		}
예제 #7
0
        public void FromXml_Null()
        {
            ZoneMembershipCondition zmc = new ZoneMembershipCondition(SecurityZone.MyComputer);

            zmc.FromXml(null);
        }