public void TestWriteReadLock_Exception() { string testpath = Path.GetRandomFileName(); Directory.CreateDirectory(testpath); IRWLock testlock = RWLockFactory.Create(testpath); try { string e = Environment.CurrentDirectory; testlock.WriteLock(); testlock.ReadLock(); } catch (ReadLockTimeoutException) { Assert.Pass(); } finally { testlock.ReadUnlock(); testlock.WriteUnlock(); } Directory.Delete(testpath, true); Assert.Fail(); }
public void TestUserReadLock_Ok() { string testpath = Path.GetRandomFileName(); Directory.CreateDirectory(testpath); IRWLock wlock = RWLockFactory.Create(testpath); using (RWLockFactory.CreateUsingReadLock(testpath)) { //was auch immer der Read tun will } //Writer sollte (wieder) erlaubt sein try { wlock.WriteLock(); } catch (WriteLockTimeoutException) { Assert.Fail(); } finally { wlock.WriteUnlock(); Directory.Delete(testpath, true); } Assert.Pass(); }