public void TestCompleteAsyncTask() { var task = new SampleWorkflow().executeAsync(3); task.Wait(); Assert.AreEqual(task.Result, 3); }
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); }
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; } }
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); }