public void Read_Lock_Should_Have_Been_Established_For_Resources_Parent_Folders()
        {
            DirectoryInfo dir = SourceFile.Directory;

            while (dir.Name != rootDirectory.Name)
            {
                var lockState = LockRepository.GetLockState(dir.FullName.ToLowerInvariant());
                Assert.AreEqual(ResourceLockState.ReadOnly, lockState, "Folder is not locked: " + dir.FullName);

                dir = dir.Parent;
            }
        }
コード例 #2
0
        public void Resource_And_Parent_Folder_Should_Have_Been_Unlocked()
        {
            Assert.AreEqual(ResourceLockState.ReadOnly, LockRepository.GetLockState(SourceFile.FullName.ToLowerInvariant()));
            Assert.AreEqual(ResourceLockState.ReadOnly, LockRepository.GetLockState(SourceFile.Directory.FullName.ToLowerInvariant()));

            //expire and wait for the scheduler to readjust
            SystemTime.Now = () => Token.ExpirationTime.Value.AddSeconds(1);
            Thread.CurrentThread.Join(500);

            Assert.AreEqual(ResourceLockState.Unlocked, LockRepository.GetLockState(SourceFile.FullName.ToLowerInvariant()));
            Assert.AreEqual(ResourceLockState.Unlocked, LockRepository.GetLockState(SourceFile.Directory.FullName.ToLowerInvariant()));
        }
        public void Getting_The_Stream_Should_Lock_File()
        {
            string resourceId = SourceFile.FullName.ToLowerInvariant();

            var state = LockRepository.GetLockState(resourceId);

            Assert.AreEqual(ResourceLockState.Unlocked, state);

            using (Stream stream = DownloadHandler.ReadFile(resourceId))
            {
                state = LockRepository.GetLockState(resourceId);
                Assert.AreEqual(ResourceLockState.ReadOnly, state);
            }
        }
 public void Read_Lock_Should_Have_Been_Established_For_Resource()
 {
     Assert.AreEqual(ResourceLockState.ReadOnly, LockRepository.GetLockState(SourceFile.FullName.ToLowerInvariant()));
 }