コード例 #1
0
 public void Clear()
 {
     lock (_dataLock)
     {
         _functionCallCountByThread.Clear();
     }
 }
コード例 #2
0
ファイル: ModulesTreeView.cs プロジェクト: zelorun/Deviare2
 protected override void RemoveAllNodes()
 {
     _moduleNodesCache.Clear();
     base.RemoveAllNodes();
 }
コード例 #3
0
        public void VisibilityTest()
        {
            context.AccessLevel = EntityAccessLevel.Administrator;
            context.Execute("DELETE FROM pubserver;");

            User user = new User(context);

            user.Username = "******";
            user.Store();

            User user2 = new User(context);

            user2.Username = "******";
            user2.Store();

            Group group = new Group(context);

            group.Name       = "groupVis";
            group.Identifier = "groupVis";
            group.Store();

            Group group2 = new Group(context);

            group2.Name       = "groupVis2";
            group2.Identifier = "groupVis2";
            group2.Store();

            group.AssignUser(user);

            PublishServer ppub = new PublishServer(context);

            ppub.Name     = "public";
            ppub.Protocol = "ftp";
            ppub.Hostname = "test.org";
            ppub.Store();
            ppub.GrantPermissionsToAll();

            PublishServer ppubresg = new PublishServer(context);

            ppubresg.Name     = "public and assigned to group";
            ppubresg.Protocol = "ftp";
            ppubresg.Hostname = "test.org";
            ppubresg.Store();
            ppubresg.GrantPermissionsToAll();
            ppubresg.GrantPermissionsToGroups(new Group[] { group });

            PublishServer ppubresg2 = new PublishServer(context);

            ppubresg2.Name     = "public and assigned to other group";
            ppubresg2.Protocol = "ftp";
            ppubresg2.Hostname = "test.org";
            ppubresg2.Store();
            ppubresg2.GrantPermissionsToAll();
            ppubresg2.GrantPermissionsToGroups(new Group[] { group2 });

            PublishServer ppubresu = new PublishServer(context);

            ppubresu.Name     = "public and assigned to user";
            ppubresu.Protocol = "ftp";
            ppubresu.Hostname = "test.org";
            ppubresu.Store();
            ppubresu.GrantPermissionsToAll();
            ppubresu.GrantPermissionsToUsers(new User[] { user });

            PublishServer ppubresu2 = new PublishServer(context);

            ppubresu2.Name     = "public and assigned to other user";
            ppubresu2.Protocol = "ftp";
            ppubresu2.Hostname = "test.org";
            ppubresu2.Store();
            ppubresu2.GrantPermissionsToAll();
            ppubresu2.GrantPermissionsToUsers(new User[] { user2 });

            PublishServer presg = new PublishServer(context);

            presg.Name     = "restricted to group";
            presg.Protocol = "ftp";
            presg.Hostname = "test.org";
            presg.Store();
            presg.GrantPermissionsToGroups(new Group[] { group });

            PublishServer presu = new PublishServer(context);

            presu.Name     = "restricted to user";
            presu.Protocol = "ftp";
            presu.Hostname = "test.org";
            presu.Store();
            presu.GrantPermissionsToUsers(new User[] { user });

            PublishServer powna = new PublishServer(context);

            powna.OwnerId  = user.Id;
            powna.Name     = "owned by user (shared with all)";
            powna.Protocol = "ftp";
            powna.Hostname = "test.org";
            powna.Store();
            powna.GrantPermissionsToAll();

            PublishServer powng = new PublishServer(context);

            powng.OwnerId  = user.Id;
            powng.Name     = "owned by user (shared with group)";
            powng.Protocol = "ftp";
            powng.Hostname = "test.org";
            powng.Store();
            powng.GrantPermissionsToGroups(new Group[] { group });

            PublishServer pownu = new PublishServer(context);

            pownu.OwnerId  = user.Id;
            pownu.Name     = "owned by user (shared with other user)";
            pownu.Protocol = "ftp";
            pownu.Hostname = "test.org";
            pownu.Store();
            pownu.GrantPermissionsToUsers(new User[] { user2 });

            PublishServer pown = new PublishServer(context);

            pown.OwnerId  = user.Id;
            pown.Name     = "owned by user (exclusive)";
            pown.Protocol = "ftp";
            pown.Hostname = "test.org";
            pown.Store();

            PublishServer pn = new PublishServer(context);

            pn.Name     = "not accessible";
            pn.Protocol = "ftp";
            pn.Hostname = "test.org";
            pn.Store();

            context.StartImpersonation(user.Id);
            context.AccessLevel = EntityAccessLevel.Privilege;
            EntityDictionary <PublishServer> pd = new EntityDictionary <PublishServer>(context);

            pd.ItemVisibility = EntityItemVisibility.All;
            pd.Load();
            Assert.AreEqual(11, pd.Count);
            Assert.IsTrue(pd.Contains(ppub.Id));
            Assert.AreEqual(EntityItemVisibility.Public, pd[ppub.Id].Visibility);
            Assert.IsTrue(pd.Contains(ppubresg.Id));
            Assert.AreEqual(EntityItemVisibility.Public, pd[ppubresg.Id].Visibility);
            Assert.IsTrue(pd.Contains(ppubresg2.Id));
            Assert.AreEqual(EntityItemVisibility.Public, pd[ppubresg2.Id].Visibility);
            Assert.IsTrue(pd.Contains(ppubresu.Id));
            Assert.AreEqual(EntityItemVisibility.Public, pd[ppubresu.Id].Visibility);
            Assert.IsTrue(pd.Contains(ppubresu2.Id));
            Assert.AreEqual(EntityItemVisibility.Public, pd[ppubresu2.Id].Visibility);
            Assert.IsTrue(pd.Contains(presg.Id));
            Assert.AreEqual(EntityItemVisibility.Restricted, pd[presg.Id].Visibility);
            Assert.IsTrue(pd.Contains(presu.Id));
            Assert.AreEqual(EntityItemVisibility.Private, pd[presu.Id].Visibility);
            Assert.IsTrue(pd.Contains(powna.Id));
            Assert.AreEqual(EntityItemVisibility.Public, pd[powna.Id].Visibility);
            Assert.IsTrue(pd.Contains(powng.Id));
            Assert.AreEqual(EntityItemVisibility.Restricted, pd[powng.Id].Visibility);
            Assert.IsTrue(pd.Contains(pownu.Id));
            Assert.AreEqual(EntityItemVisibility.Restricted, pd[pownu.Id].Visibility);
            Assert.IsTrue(pd.Contains(pown.Id));
            Assert.AreEqual(EntityItemVisibility.Private, pd[pown.Id].Visibility);

            pd.Clear();
            pd.ItemVisibility = EntityItemVisibility.Public;
            pd.Load();
            Assert.AreEqual(6, pd.Count);
            Assert.IsTrue(pd.Contains(ppub.Id));
            Assert.IsTrue(pd.Contains(ppubresg.Id));
            Assert.IsTrue(pd.Contains(ppubresg2.Id));
            Assert.IsTrue(pd.Contains(ppubresu.Id));
            Assert.IsTrue(pd.Contains(ppubresu2.Id));
            Assert.IsTrue(pd.Contains(powna.Id));

            pd.Clear();
            pd.ItemVisibility = EntityItemVisibility.Restricted;
            pd.Load();
            Assert.AreEqual(3, pd.Count);
            Assert.IsTrue(pd.Contains(presg.Id));
            Assert.IsTrue(pd.Contains(powng.Id));
            Assert.IsTrue(pd.Contains(pownu.Id));

            pd.Clear();
            pd.ItemVisibility = EntityItemVisibility.Private;
            pd.Load();
            Assert.AreEqual(2, pd.Count);
            Assert.IsTrue(pd.Contains(presu.Id));
            Assert.IsTrue(pd.Contains(pown.Id));

            pd.Clear();
            pd.ItemVisibility = EntityItemVisibility.Public | EntityItemVisibility.Restricted;
            pd.Load();
            Assert.AreEqual(9, pd.Count);
            Assert.IsTrue(pd.Contains(ppub.Id));
            Assert.IsTrue(pd.Contains(ppubresg.Id));
            Assert.IsTrue(pd.Contains(ppubresg2.Id));
            Assert.IsTrue(pd.Contains(ppubresu.Id));
            Assert.IsTrue(pd.Contains(ppubresu2.Id));
            Assert.IsTrue(pd.Contains(presg.Id));
            Assert.IsTrue(pd.Contains(powna.Id));
            Assert.IsTrue(pd.Contains(powng.Id));
            Assert.IsTrue(pd.Contains(pownu.Id));

            pd.Clear();
            pd.ItemVisibility = EntityItemVisibility.Public | EntityItemVisibility.Private;
            pd.Load();
            Assert.AreEqual(8, pd.Count);
            Assert.IsTrue(pd.Contains(ppub.Id));
            Assert.IsTrue(pd.Contains(ppubresg.Id));
            Assert.IsTrue(pd.Contains(ppubresg2.Id));
            Assert.IsTrue(pd.Contains(ppubresu.Id));
            Assert.IsTrue(pd.Contains(ppubresu2.Id));
            Assert.IsTrue(pd.Contains(presu.Id));
            Assert.IsTrue(pd.Contains(powna.Id));
            Assert.IsTrue(pd.Contains(pown.Id));

            pd.Clear();
            pd.ItemVisibility = EntityItemVisibility.All | EntityItemVisibility.OwnedOnly;
            pd.Load();
            Assert.AreEqual(4, pd.Count);
            Assert.IsTrue(pd.Contains(powna.Id));
            Assert.IsTrue(pd.Contains(powng.Id));
            Assert.IsTrue(pd.Contains(pownu.Id));
            Assert.IsTrue(pd.Contains(pown.Id));

            pd.Clear();
            pd.ItemVisibility = EntityItemVisibility.Public | EntityItemVisibility.OwnedOnly;
            pd.Load();
            Assert.AreEqual(1, pd.Count);
            Assert.IsTrue(pd.Contains(powna.Id));

            pd.Clear();
            pd.ItemVisibility = EntityItemVisibility.Restricted | EntityItemVisibility.OwnedOnly;
            pd.Load();
            Assert.AreEqual(2, pd.Count);
            Assert.IsTrue(pd.Contains(powng.Id));
            Assert.IsTrue(pd.Contains(pownu.Id));

            pd.Clear();
            pd.ItemVisibility = EntityItemVisibility.Private | EntityItemVisibility.OwnedOnly;
            pd.Load();
            Assert.AreEqual(1, pd.Count);
            Assert.IsTrue(pd.Contains(pown.Id));

            context.EndImpersonation();
        }