public void Wait_QueuesWork() { var l = new AsyncLock(); var l1 = false; var l2 = false; l.Wait(() => { l.Wait(() => { Assert.IsTrue(l1); l2 = true; }); l1 = true; }); Assert.IsTrue(l2); }
public void Wait_Fail() { var l = new AsyncLock(); var ex = new Exception(); try { l.Wait(() => { throw ex; }); Assert.Fail(); } catch (Exception e) { Assert.AreSame(ex, e); } // has faulted; should not run l.Wait(() => { Assert.Fail(); }); }
public void Dispose() { var l = new AsyncLock(); var l1 = false; var l2 = false; var l3 = false; var l4 = false; l.Wait(() => { l.Wait(() => { l.Wait(() => { l3 = true; }); l2 = true; l.Dispose(); l.Wait(() => { l4 = true; }); }); l1 = true; }); Assert.IsTrue(l1); Assert.IsTrue(l2); Assert.IsFalse(l3); Assert.IsFalse(l4); }
public void Wait_ArgumentChecking() { var asyncLock = new AsyncLock(); asyncLock.Wait(null); }
public void Wait_ArgumentChecking() { var asyncLock = new AsyncLock(); Assert.Throws<ArgumentNullException>(() => asyncLock.Wait(null)); }