public void Lock() { using (var tester = new RemoteLockerTester()) { var lockId = Guid.NewGuid().ToString(); var lock1 = tester.Lock(lockId); Assert.That(tester.TryGetLock(lockId, out var lock2), Is.False); lock1.Dispose(); Assert.That(tester.TryGetLock(lockId, out lock2), Is.True); lock2.Dispose(); } }
public void TryLock_DifferentLockIds() { using (var tester = new RemoteLockerTester()) { var lockId1 = Guid.NewGuid().ToString(); var lockId2 = Guid.NewGuid().ToString(); var lockId3 = Guid.NewGuid().ToString(); Assert.That(tester.TryGetLock(lockId1, out var lock1), Is.True); Assert.That(tester.TryGetLock(lockId2, out var lock2), Is.True); Assert.That(tester.TryGetLock(lockId3, out var lock3), Is.True); lock1.Dispose(); lock2.Dispose(); lock3.Dispose(); } }
public void TryLock_SingleLockId() { using (var tester = new RemoteLockerTester()) { var lockId = Guid.NewGuid().ToString(); Assert.That(tester.TryGetLock(lockId, out var lock1), Is.True); Assert.That(lock1, Is.Not.Null); Assert.That(tester.TryGetLock(lockId, out var lock2), Is.False); Assert.That(lock2, Is.Null); lock1.Dispose(); Assert.That(tester.TryGetLock(lockId, out lock2), Is.True); Assert.That(lock2, Is.Not.Null); lock2.Dispose(); } }