示例#1
0
        public void MakeSurePuttingSeveralLocksOnSameThingCleanUpNicelyWhenYouReleaseTheLocks()
        {
            var manager = new FileSystemObjectLockingManager();

            var folderNodes = FakeNodesFactory.CreateFakeFolderNodes(2);

            var fileNode = FakeNodesFactory.CreateFakeFileNode();

            var nodeResolvingResult = new NodeWithSurroundingsResolvingResult <FileNode>(folderNodes, fileNode, FakeNodesFactory.CreateFakeFolderNodes(1).First());

            Guid lockId  = manager.AcquireLock(nodeResolvingResult, LockKind.Read);
            Guid lock2Id = manager.AcquireLock(nodeResolvingResult, LockKind.Read);
            Guid lock3Id = manager.AcquireLock(nodeResolvingResult, LockKind.Read);

            Assert.IsTrue(manager.IsNodeLockedForRenamesAndMoves(folderNodes[0]));
            Assert.IsTrue(manager.IsNodeLockedForRenamesAndMoves(folderNodes[1]));

            manager.ReleaseLock(lockId);
            manager.ReleaseLock(lock3Id);

            Assert.IsTrue(manager.IsNodeLockedForRenamesAndMoves(folderNodes[0]));
            Assert.IsTrue(manager.IsNodeLockedForRenamesAndMoves(folderNodes[1]));

            manager.ReleaseLock(lock2Id);

            Assert.IsFalse(manager.IsNodeLockedForRenamesAndMoves(folderNodes[0]));
            Assert.IsFalse(manager.IsNodeLockedForRenamesAndMoves(folderNodes[1]));
        }
示例#2
0
        public void MakeSureAcquiringALockDoesLockAppropriateFolders()
        {
            var manager = new FileSystemObjectLockingManager();

            var folderNodes = FakeNodesFactory.CreateFakeFolderNodes(2);

            var fileNode = FakeNodesFactory.CreateFakeFileNode();

            var nodeResolvingResult = new NodeWithSurroundingsResolvingResult <FileNode>(folderNodes, fileNode, FakeNodesFactory.CreateFakeFolderNodes(1).First());

            Guid lockId = manager.AcquireLock(nodeResolvingResult, LockKind.Read);

            Assert.IsTrue(manager.IsNodeLockedForRenamesAndMoves(folderNodes[0]));
            Assert.IsTrue(manager.IsNodeLockedForRenamesAndMoves(folderNodes[1]));

            manager.ReleaseLock(lockId);

            Assert.IsFalse(manager.IsNodeLockedForRenamesAndMoves(folderNodes[0]));
            Assert.IsFalse(manager.IsNodeLockedForRenamesAndMoves(folderNodes[1]));
        }