Example #1
0
        public void MakeSureNoFolderIsLockedAfterManagerCreation()
        {
            var manager = new FileSystemObjectLockingManager();

            Assert.IsFalse(manager.IsNodeLockedForRenamesAndMoves(FakeNodesFactory.CreateFakeFolderNodes(1).First()));
            Assert.IsFalse(manager.IsNodeLockedForRenamesAndMoves(FakeNodesFactory.CreateFakeFolderNodes(1).First()));
            Assert.IsFalse(manager.IsNodeLockedForRenamesAndMoves(FakeNodesFactory.CreateFakeFolderNodes(1).First()));
        }
Example #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]));
        }
Example #3
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]));
        }