示例#1
0
        public void TestCompleteAsyncTask()
        {
            var task = new SampleWorkflow().executeAsync(3);

            task.Wait();
            Assert.AreEqual(task.Result, 3);
        }
示例#2
0
        public void TestProgressOfAsyncTask2()
        {
            Double progressResult = .0;
              var progress = new Progress<Double>();
              progress.ProgressChanged += (s, e) => {
            progressResult = e;
              };

              var task = new SampleWorkflow().executeAsync(3, progress);
              task.Wait();

              Assert.AreEqual(3, task.Result);
              Assert.AreEqual(100.0, progressResult);
        }
示例#3
0
 public void TestCancelAsyncTask()
 {
     var cancelTknSrc = new CancellationTokenSource();
       var task = new SampleWorkflow().executeAsync(3, cancelTknSrc.Token);
       cancelTknSrc.Cancel();
       try
       {
     task.Wait();
       }
       catch (AggregateException e)
       {
     throw e.InnerException;
       }
 }
示例#4
0
        public void TestCancelAsyncTask()
        {
            var cancelTknSrc = new CancellationTokenSource();
            var task         = new SampleWorkflow().executeAsync(3, cancelTknSrc.Token);

            cancelTknSrc.Cancel();
            try
            {
                task.Wait();
            }
            catch (AggregateException e)
            {
                throw e.InnerException;
            }
        }
示例#5
0
        public void TestProgressOfAsyncTask2()
        {
            Double progressResult = .0;
            var    progress       = new Progress <Double>();

            progress.ProgressChanged += (s, e) => {
                progressResult = e;
            };

            var task = new SampleWorkflow().executeAsync(3, progress);

            task.Wait();

            Assert.AreEqual(3, task.Result);
            Assert.AreEqual(100.0, progressResult);
        }
示例#6
0
 public void TestCompleteAsyncTask()
 {
     var task = new SampleWorkflow().executeAsync(3);
       task.Wait();
       Assert.AreEqual(task.Result, 3);
 }