public void CurrentThreadOnTest() { var inCheck = false; var outCheck = false; var worker = new WorkerQueue(); worker.Queue(() => { inCheck = worker.CurrentThreadOn(); }); worker.Wait(); outCheck = worker.CurrentThreadOn(); Assert.IsTrue(inCheck); Assert.IsFalse(outCheck); }
public void QueueTest() { var sequence = 0; var worker = new WorkerQueue(); worker.Queue(() => { Assert.AreEqual(0, sequence); Thread.Sleep(100); ++sequence; }); worker.Queue(() => { Assert.AreEqual(1, sequence); Thread.Sleep(10); ++sequence; }); worker.Queue(() => { Assert.AreEqual(2, sequence); Thread.Sleep(0); ++sequence; }); worker.Queue(() => { Assert.AreEqual(3, sequence); Thread.Sleep(50); ++sequence; }); worker.Queue(() => { Assert.AreEqual(4, sequence); Thread.Sleep(150); ++sequence; }); worker.Queue(() => { Assert.AreEqual(5, sequence); Thread.Sleep(1); ++sequence; }); worker.Wait(); Assert.AreEqual(6, sequence); }