public void MainTest() { AsyncPump.Run( async() => { var counter = 0; var queue = new WorkQueue(); queue.Enqueue(() => ++ counter).Ignore(); await queue.Enqueue(() => ++ counter); Assert.AreEqual(2, counter); }); }
public void MainTest() { AsyncPump.Run( async() => { var singleton = new TaskSingleton(); var task1 = singleton.Execute(() => Task.Delay(250)); await AssertThrowAsync <InvalidOperationException>(() => singleton.Execute(() => Task.Delay(250))); await task1; var value = this.Random.Next(); Assert.AreEqual(value, await singleton.Execute(() => Task.FromResult(value))); }); }
public void ExceptionTest() { AssertThrow <ArgumentNullException>(() => AsyncPump.Run(null)); AssertThrow <ArgumentException>(() => AsyncPump.Run(() => null)); AsyncPump.Run( () => { AssertThrow <NotSupportedException>(() => SynchronizationContext.Current.Send(o => { }, null)); AssertThrow <ArgumentNullException>(() => SynchronizationContext.Current.Post(null, new object())); return(Task.FromResult(false)); }); AssertThrow <InvalidOperationException>( () => AsyncPump.Run(() => { throw new InvalidOperationException(); })); }
public void MainTest() { AsyncPump.Run( async() => { var counter = 0; var queue = new TaskQueue(); queue.Enqueue( async() => { await Task.Delay(250); ++counter; }).Ignore(); Assert.AreEqual(2, await queue.Enqueue(() => Task.FromResult(++counter))); Assert.AreEqual(2, counter); }); }
public void MainTest() { LogMethodPosition("Begin"); AsyncPump.Run(DoEverything); LogMethodPosition("End"); }