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()); }
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); }
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); }