Union() public method

public Union ( IPermission target ) : IPermission
target IPermission
return IPermission
Beispiel #1
0
		public void Union_SmtpAccess ()
		{
			SmtpPermission spn = new SmtpPermission (false);
			SmtpPermission spu = new SmtpPermission (true);
			SmtpPermission spctup = new SmtpPermission (SmtpAccess.ConnectToUnrestrictedPort);
			SmtpPermission spconnect = new SmtpPermission (SmtpAccess.Connect);
			SmtpPermission spnone = new SmtpPermission (SmtpAccess.None);

			SmtpPermission union = (SmtpPermission) spn.Union (spctup);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "None U ConnectToUnrestrictedPort");
			union = (SmtpPermission) spn.Union (spconnect);
			Assert.AreEqual (SmtpAccess.Connect, union.Access, "None U Connect");
			union = (SmtpPermission) spn.Union (spnone);
			Assert.AreEqual (SmtpAccess.None, union.Access, "None U SmtpAccess.None");

			union = (SmtpPermission) spu.Union (spctup);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "Unrestricted U ConnectToUnrestrictedPort");
			union = (SmtpPermission) spu.Union (spconnect);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "Unrestricted U Connect");
			union = (SmtpPermission) spu.Union (spnone);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "Unrestricted U SmtpAccess.None");

			union = (SmtpPermission) spctup.Union (spctup);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "ConnectToUnrestrictedPort U ConnectToUnrestrictedPort");
			union = (SmtpPermission) spctup.Union (spconnect);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "ConnectToUnrestrictedPort U Connect");
			union = (SmtpPermission) spctup.Union (spnone);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "ConnectToUnrestrictedPort U SmtpAccess.None");
			union = (SmtpPermission) spctup.Union (spn);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "ConnectToUnrestrictedPort U None");
			union = (SmtpPermission) spctup.Union (spu);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "ConnectToUnrestrictedPort U Unrestricted");

			union = (SmtpPermission) spconnect.Union (spctup);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "Connect U ConnectToUnrestrictedPort");
			union = (SmtpPermission) spconnect.Union (spconnect);
			Assert.AreEqual (SmtpAccess.Connect, union.Access, "Connect U Connect");
			union = (SmtpPermission) spconnect.Union (spnone);
			Assert.AreEqual (SmtpAccess.Connect, union.Access, "Connect U SmtpAccess.None");
			union = (SmtpPermission) spconnect.Union (spn);
			Assert.AreEqual (SmtpAccess.Connect, union.Access, "Connect U None");
			union = (SmtpPermission) spconnect.Union (spu);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "Connect U Unrestricted");

			union = (SmtpPermission) spnone.Union (spctup);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "SmtpAccess.None U ConnectToUnrestrictedPort");
			union = (SmtpPermission) spnone.Union (spconnect);
			Assert.AreEqual (SmtpAccess.Connect, union.Access, "SmtpAccess.None U Connect");
			union = (SmtpPermission) spnone.Union (spnone);
			Assert.AreEqual (SmtpAccess.None, union.Access, "SmtpAccess.None U SmtpAccess.None");
			union = (SmtpPermission) spnone.Union (spn);
			Assert.AreEqual (SmtpAccess.None, union.Access, "SmtpAccess.None U None");
			union = (SmtpPermission) spnone.Union (spu);
			Assert.AreEqual (SmtpAccess.ConnectToUnrestrictedPort, union.Access, "SmtpAccess.None U Unrestricted");
		}
Beispiel #2
0
		public void Union_BadPermission ()
		{
			SmtpPermission sp = new SmtpPermission (PermissionState.None);
			sp.Union (new SecurityPermission (PermissionState.Unrestricted));
		}
Beispiel #3
0
		public void Union ()
		{
			SmtpPermission spn = new SmtpPermission (PermissionState.None);
			SmtpPermission spu = new SmtpPermission (PermissionState.Unrestricted);

			SmtpPermission result = (SmtpPermission) spn.Union (null);
			Assert.IsFalse (result.IsUnrestricted (), "None U null");

			result = (SmtpPermission) spu.Union (null);
			Assert.IsTrue (result.IsUnrestricted (), "Unrestricted U null");

			result = (SmtpPermission) spn.Union (spn);
			Assert.IsFalse (result.IsUnrestricted (), "None U None");

			result = (SmtpPermission) spu.Union (spu);
			Assert.IsTrue (result.IsUnrestricted (), "Unrestricted U Unrestricted");

			result = (SmtpPermission) spn.Union (spu);
			Assert.IsTrue (result.IsUnrestricted (), "None U Unrestricted");

			result = (SmtpPermission) spu.Union (spn);
			Assert.IsTrue (result.IsUnrestricted (), "Unrestricted U None");
		}