Union() public method

public Union ( IPermission other ) : IPermission
other IPermission
return IPermission
		public void Union_Bug79118 ()
		{
			string[] f1 = unix ? new string[] { "/tmp/one", "/tmp/two" } : new string[] { "c:\\temp\\one", "c:\\temp\\two" };
			string[] f2 = unix ? new string[] { "/tmp/two" } : new string[] { "c:\\temp\\two" };

			p = new FileIOPermission (FileIOPermissionAccess.Read, f1);
			p2 = new FileIOPermission (FileIOPermissionAccess.Read, f2);
			FileIOPermission union = (FileIOPermission) p.Union (p2);

			string[] paths = union.GetPathList(FileIOPermissionAccess.Read);
			Assert.AreEqual (2, paths.Length, "Length");
			Assert.AreEqual (f1[0], paths[0], "0");
			Assert.AreEqual (f1[1], paths[1], "1");
		}
		private void Partial (string msg, string[] path1, string[] path2, int expected)
		{
			p = new FileIOPermission (FileIOPermissionAccess.Read, path1);
			p2 = new FileIOPermission (FileIOPermissionAccess.Read, path2);
			FileIOPermission union = (FileIOPermission) p.Union (p2);

			string[] paths = union.GetPathList(FileIOPermissionAccess.Read);
			Assert.AreEqual (expected, paths.Length, msg + ".Length");
			Assert.AreEqual (path1[0], paths[0], msg + "[0]");
			if (expected > 1)
				Assert.AreEqual (path2[0], paths[1], msg + "[1]");
		}
		public void Union ()
		{
			unrestricted = new FileIOPermission(PermissionState.Unrestricted);
			p = new FileIOPermission(FileIOPermissionAccess.Read, pathArrayGood);

			FileIOPermission union = (FileIOPermission)unrestricted.Union(p);
			pathsInPermission = union.GetPathList(FileIOPermissionAccess.Read);
			Assert.IsTrue(union.IsUnrestricted(), "Should get an unrestricted permission");
			Assert.IsTrue(pathsInPermission == null, "Path list should be empty");

			union = (FileIOPermission)p.Union(unrestricted);
			pathsInPermission = union.GetPathList(FileIOPermissionAccess.Read);
			Assert.IsTrue(union.IsUnrestricted(), "Should get an unrestricted permission");
			Assert.IsTrue(pathsInPermission == null, "Path list should be empty");

			p2 = new FileIOPermission(FileIOPermissionAccess.Append, pathArrayGood2);

			union = (FileIOPermission)p.Union(p2);
			pathsInPermission = union.GetPathList(FileIOPermissionAccess.Read);
			Assert.IsTrue(pathsInPermission.Length == pathArrayGood.Length, "Path list should have 2 for Read");
			pathsInPermission = union.GetPathList(FileIOPermissionAccess.Append);
			Assert.IsTrue(pathsInPermission.Length == pathArrayGood2.Length, "Path list should have 3 for Append");

			union = (FileIOPermission)p2.Union(p);
			pathsInPermission = union.GetPathList(FileIOPermissionAccess.Read);
			Assert.IsTrue(pathsInPermission.Length == pathArrayGood.Length, "Path list should have 2 for Read");
			pathsInPermission = union.GetPathList(FileIOPermissionAccess.Append);
			Assert.IsTrue(pathsInPermission.Length == pathArrayGood2.Length, "Path list should have 3 for Append");
		}