Union() public method

public Union ( IPermission target ) : IPermission
target IPermission
return IPermission
		public void Union_DifferentPermissions ()
		{
			UIPermission a = new UIPermission (PermissionState.None);
			SecurityPermission b = new SecurityPermission (PermissionState.None);
			a.Union (b);
		}
		public void Union ()
		{
			UIPermission none = new UIPermission (PermissionState.None);
			UIPermission union = (UIPermission)none.Union (null);
			Compare (none, union, "none U null");
			Assert.IsFalse (Object.ReferenceEquals (none, union), "!ReferenceEquals1");
			Assert.IsTrue (none.IsSubsetOf (union), "none.IsSubsetOf (union)");

			union = (UIPermission)none.Union (new UIPermission (PermissionState.None));
			Assert.IsNull (union, "none U none");
			Assert.IsTrue (none.IsSubsetOf (null), "none.IsSubsetOf (null)");

			UIPermission unrestricted = new UIPermission (PermissionState.Unrestricted);
			union = (UIPermission)none.Union (unrestricted);
			Compare (unrestricted, union, "none U unrestricted");
			Assert.IsTrue (union.IsUnrestricted (), "IsUnrestricted-1");
			Assert.IsFalse (Object.ReferenceEquals (unrestricted, union), "!ReferenceEquals2");
			Assert.IsTrue (none.IsSubsetOf (union), "none.IsSubsetOf (union)");
			Assert.IsTrue (unrestricted.IsSubsetOf (union), "unrestricted.IsSubsetOf (union)");

			union = (UIPermission)unrestricted.Union (unrestricted);
			Compare (unrestricted, union, "unrestricted U unrestricted");
			Assert.IsTrue (union.IsUnrestricted (), "IsUnrestricted-2");
			Assert.IsFalse (Object.ReferenceEquals (unrestricted, union), "!ReferenceEquals3");
			Assert.IsTrue (unrestricted.IsSubsetOf (union), "unrestricted.IsSubsetOf (union)");

			UIPermission clip_all = new UIPermission (UIPermissionClipboard.AllClipboard);
			UIPermission win_all = new UIPermission (UIPermissionWindow.AllWindows);
			union = (UIPermission)clip_all.Union (win_all);
			Compare (unrestricted, union, "clip_all U win_all");
			Assert.IsTrue (union.IsUnrestricted (), "IsUnrestricted-3");
			Assert.IsTrue (clip_all.IsSubsetOf (union), "clip_all.IsSubsetOf (union)");
			Assert.IsTrue (win_all.IsSubsetOf (union), "win_all.IsSubsetOf (union)");
		}