public void TestReadWriteLock()
 {
     var testDir = new DirectoryInfo(Path.Combine(tempDir.FullName, Guid.NewGuid().ToString()));
     testDir.Create();
     var locker = new DirectoryLocker(testDir.FullName);
     locker.ReadWriteLock();
     Assert.AreEqual(1, testDir.GetFiles("readwrite.lock").Count());
 }
 public void TestWaitReadWriteUnlock()
 {
     var testDir = new DirectoryInfo(Path.Combine(tempDir.FullName, Guid.NewGuid().ToString()));
     testDir.Create();
     var testLocker = new DirectoryLocker(testDir.FullName);
     testLocker.ReadWriteLock();
     Task.Factory.StartNew(() => {
         ReadWriteUnLock(testLocker, 5);
     });
     var locker = new DirectoryLocker(testDir.FullName);
     var start = DateTime.Now;
     locker.WaitReadWriteUnlock(10, 1000);
     var finish = DateTime.Now;
     var delta = finish - start;
     Assert.IsTrue(delta.TotalSeconds > 3);
 }