Esempio n. 1
0
        public void ExceptionTest()
        {
            var queue = new TaskSingleton();

            AssertThrow <ArgumentNullException>(
                () => queue.Execute(null),
                () => queue.Execute((Func <Task <string> >)null));
        }
Esempio n. 2
0
 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)));
     });
 }