Exemple #1
0
        public void AttemptToAcquireLockWhenAlreadyLocked()
        {
            string     parentPath                 = Path.Combine("mock:", "path", "to");
            string     lockPath                   = Path.Combine(parentPath, "lock");
            MockTracer tracer                     = new MockTracer();
            FileBasedLockFileSystem fs            = new FileBasedLockFileSystem();
            FileBasedLock           fileBasedLock = new WindowsFileBasedLock(fs, tracer, lockPath);

            fileBasedLock.TryAcquireLock().ShouldBeTrue();
            Assert.Throws <InvalidOperationException>(() => fileBasedLock.TryAcquireLock());
        }
Exemple #2
0
        public void CreateLockWhenDirectoryMissing()
        {
            string     parentPath                 = Path.Combine("mock:", "path", "to");
            string     lockPath                   = Path.Combine(parentPath, "lock");
            MockTracer tracer                     = new MockTracer();
            FileBasedLockFileSystem fs            = new FileBasedLockFileSystem();
            FileBasedLock           fileBasedLock = new WindowsFileBasedLock(fs, tracer, lockPath);

            fileBasedLock.TryAcquireLock().ShouldBeTrue();
            fs.CreateDirectoryPath.ShouldNotBeNull();
            fs.CreateDirectoryPath.ShouldEqual(parentPath);
        }
Exemple #3
0
        public void CreateLockWhenDirectoryMissing()
        {
            string     parentPath                 = Path.Combine("mock:", "path", "to");
            string     lockPath                   = Path.Combine(parentPath, "lock");
            MockTracer tracer                     = new MockTracer();
            FileBasedLockFileSystem fs            = new FileBasedLockFileSystem();
            FileBasedLock           fileBasedLock = new FileBasedLock(fs, tracer, lockPath, "signature", overwriteExistingLock: true);

            fileBasedLock.TryAcquireLockAndDeleteOnClose().ShouldBeTrue();
            fs.CreateDirectoryPath.ShouldNotBeNull();
            fs.CreateDirectoryPath.ShouldEqual(parentPath);
        }