public void Union_DifferentPermissions () { IsolatedStorageFilePermission a = new IsolatedStorageFilePermission (PermissionState.None); SecurityPermission b = new SecurityPermission (PermissionState.None); a.Union (b); }
public void UsageAllowedQuota () { IsolatedStorageFilePermission empty = new IsolatedStorageFilePermission (PermissionState.None); IsolatedStorageFilePermission small = new IsolatedStorageFilePermission (PermissionState.None); small.UsageAllowed = IsolatedStorageContainment.DomainIsolationByUser; small.UserQuota = 1; IsolatedStorageFilePermission union = (IsolatedStorageFilePermission)empty.Union (small); Assert.AreEqual (IsolatedStorageContainment.DomainIsolationByUser, union.UsageAllowed, "DomainIsolationByUser"); Assert.AreEqual (1, union.UserQuota, "1"); Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-1"); Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-1a"); Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-1b"); Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-1c"); IsolatedStorageFilePermission intersect = (IsolatedStorageFilePermission)union.Intersect (small); Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-1"); Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-1"); small.UsageAllowed = IsolatedStorageContainment.AssemblyIsolationByUser; small.UserQuota = 2; union = (IsolatedStorageFilePermission)union.Union (small); Assert.AreEqual (IsolatedStorageContainment.AssemblyIsolationByUser, union.UsageAllowed, "AssemblyIsolationByUser"); Assert.AreEqual (2, union.UserQuota, "2"); Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-2"); Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-2a"); Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-2b"); Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-2c"); intersect = (IsolatedStorageFilePermission)union.Intersect (small); Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-2"); Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-2"); small.UsageAllowed = IsolatedStorageContainment.ApplicationIsolationByUser; small.UserQuota = 3; union = (IsolatedStorageFilePermission)union.Union (small); Assert.AreEqual (IsolatedStorageContainment.AssemblyIsolationByUser, union.UsageAllowed, "ApplicationIsolationByUser"); Assert.AreEqual (3, union.UserQuota, "3"); Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-3"); Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-3a"); Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-3b"); Assert.IsFalse (union.IsSubsetOf (small), "IsSubset-3c"); intersect = (IsolatedStorageFilePermission)union.Intersect (small); Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-3"); Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-3"); small.UsageAllowed = IsolatedStorageContainment.DomainIsolationByMachine; small.UserQuota = 4; union = (IsolatedStorageFilePermission)union.Union (small); Assert.AreEqual (IsolatedStorageContainment.DomainIsolationByMachine, union.UsageAllowed, "DomainIsolationByMachine"); Assert.AreEqual (4, union.UserQuota, "4"); Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-4"); Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-4a"); Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-4b"); Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-4c"); intersect = (IsolatedStorageFilePermission)union.Intersect (small); Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-4"); Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-4"); small.UsageAllowed = IsolatedStorageContainment.AssemblyIsolationByMachine; small.UserQuota = 5; union = (IsolatedStorageFilePermission)union.Union (small); Assert.AreEqual (IsolatedStorageContainment.AssemblyIsolationByMachine, union.UsageAllowed, "AssemblyIsolationByMachine"); Assert.AreEqual (5, union.UserQuota, "5"); Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-5"); Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-5a"); Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-5b"); Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-5c"); intersect = (IsolatedStorageFilePermission)union.Intersect (small); Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-5"); Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-5"); small.UsageAllowed = IsolatedStorageContainment.ApplicationIsolationByMachine; small.UserQuota = 6; union = (IsolatedStorageFilePermission)union.Union (small); Assert.AreEqual (IsolatedStorageContainment.ApplicationIsolationByMachine, union.UsageAllowed, "ApplicationIsolationByMachine"); Assert.AreEqual (6, union.UserQuota, "6"); Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-6"); Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-6a"); Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-6b"); Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-6c"); intersect = (IsolatedStorageFilePermission)union.Intersect (small); Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-6"); Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-6"); small.UsageAllowed = IsolatedStorageContainment.DomainIsolationByRoamingUser; small.UserQuota = 7; union = (IsolatedStorageFilePermission)union.Union (small); Assert.AreEqual (IsolatedStorageContainment.DomainIsolationByRoamingUser, union.UsageAllowed, "DomainIsolationByRoamingUser"); Assert.AreEqual (7, union.UserQuota, "7a"); Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-7a"); Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-7a"); Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-7b"); Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-7c"); intersect = (IsolatedStorageFilePermission)union.Intersect (small); Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-7"); Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-7"); // can't go back ;-) small.UsageAllowed = IsolatedStorageContainment.DomainIsolationByUser; small.UserQuota = 1; union = (IsolatedStorageFilePermission)union.Union (small); Assert.AreEqual (IsolatedStorageContainment.DomainIsolationByRoamingUser, union.UsageAllowed, "DomainIsolationByRoamingUser"); Assert.AreEqual (7, union.UserQuota, "7b"); Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-7b"); small.UsageAllowed = IsolatedStorageContainment.AssemblyIsolationByRoamingUser; small.UserQuota = 7; // no change union = (IsolatedStorageFilePermission)union.Union (small); Assert.AreEqual (IsolatedStorageContainment.AssemblyIsolationByRoamingUser, union.UsageAllowed, "AssemblyIsolationByRoamingUser"); Assert.AreEqual (7, union.UserQuota, "7c"); Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-7c"); small.UsageAllowed = IsolatedStorageContainment.ApplicationIsolationByRoamingUser; small.UserQuota = 8; union = (IsolatedStorageFilePermission)union.Union (small); Assert.AreEqual (IsolatedStorageContainment.ApplicationIsolationByRoamingUser, union.UsageAllowed, "ApplicationIsolationByRoamingUser"); Assert.AreEqual (8, union.UserQuota, "8"); Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-8"); Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-8a"); Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-8b"); Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-8c"); intersect = (IsolatedStorageFilePermission)union.Intersect (small); Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-8"); Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-8"); small.UsageAllowed = IsolatedStorageContainment.AdministerIsolatedStorageByUser; small.UserQuota = 9; union = (IsolatedStorageFilePermission)union.Union (small); Assert.AreEqual (IsolatedStorageContainment.AdministerIsolatedStorageByUser, union.UsageAllowed, "AdministerIsolatedStorageByUser"); Assert.AreEqual (9, union.UserQuota, "9"); Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-9"); Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-9a"); Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-9b"); Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-9c"); intersect = (IsolatedStorageFilePermission)union.Intersect (small); Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-9"); Assert.AreEqual (small.UserQuota, intersect.UserQuota, "Intersect-UserQuota-9"); small.UsageAllowed = IsolatedStorageContainment.UnrestrictedIsolatedStorage; small.UserQuota = 10; union = (IsolatedStorageFilePermission)union.Union (small); Assert.AreEqual (IsolatedStorageContainment.UnrestrictedIsolatedStorage, union.UsageAllowed, "UnrestrictedIsolatedStorage"); Assert.AreEqual (Int64.MaxValue, union.UserQuota, "10"); Assert.IsTrue (union.IsUnrestricted (), "IsUnrestricted-10"); Assert.IsTrue (small.IsSubsetOf (union), "IsSubset-10a"); Assert.IsTrue (empty.IsSubsetOf (union), "IsSubset-10b"); Assert.IsTrue (union.IsSubsetOf (small), "IsSubset-10c"); intersect = (IsolatedStorageFilePermission)union.Intersect (small); Assert.AreEqual (small.UsageAllowed, intersect.UsageAllowed, "Intersect-UsageAllowed-10"); Assert.IsFalse ((small.UserQuota == intersect.UserQuota), "Intersect-UserQuota-10"); }
public void Union () { IsolatedStorageFilePermission empty = new IsolatedStorageFilePermission (PermissionState.None); IsolatedStorageFilePermission union = (IsolatedStorageFilePermission)empty.Union (null); Assert.IsNotNull (union, "empty U null"); Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-1"); Assert.IsFalse (Object.ReferenceEquals (empty, union), "ReferenceEquals-1"); union = (IsolatedStorageFilePermission)empty.Union (empty); Assert.IsNotNull (union, "empty U empty"); Assert.IsFalse (union.IsUnrestricted (), "IsUnrestricted-2"); Assert.IsFalse (Object.ReferenceEquals (empty, union), "ReferenceEquals-2"); IsolatedStorageFilePermission unrestricted = new IsolatedStorageFilePermission (PermissionState.Unrestricted); union = (IsolatedStorageFilePermission)unrestricted.Union (null); Assert.IsNotNull (union, "unrestricted U null"); Assert.IsTrue (union.IsUnrestricted (), "IsUnrestricted-3"); Assert.IsFalse (Object.ReferenceEquals (unrestricted, union), "ReferenceEquals-3"); union = (IsolatedStorageFilePermission)unrestricted.Union (empty); Assert.IsNotNull (union, "unrestricted U empty"); Assert.IsTrue (union.IsUnrestricted (), "IsUnrestricted-4"); Assert.IsFalse (Object.ReferenceEquals (unrestricted, union), "ReferenceEquals-4"); union = (IsolatedStorageFilePermission)unrestricted.Union (unrestricted); Assert.IsNotNull (union, "unrestricted U unrestricted"); Assert.IsTrue (union.IsUnrestricted (), "IsUnrestricted-5"); Assert.IsFalse (Object.ReferenceEquals (unrestricted, union), "ReferenceEquals-5"); }