public async Task ExceptionPropagatesOutIfNoFinally() { var runOrder = new List <string>(); var task = new ActionTask(Token, _ => { throw new InvalidOperationException(); }) .Catch(_ => { }); await task.StartAsAsync(); }
public async Task ExceptionPropagatesOutIfNoFinally() { var task = new ActionTask(Token, _ => { throw new InvalidOperationException(); }) .Catch(_ => { }); Func <Task> act = async() => await task.StartAsAsync(); await act.Should().ThrowAsync <InvalidOperationException>(); }
public async Task Inlining() { var runOrder = new List <string>(); var act = new ActionTask(Token, _ => runOrder.Add($"started")) .Then(TaskEx.FromResult(1), TaskAffinity.Exclusive) .Then((_, n) => n + 1) .Then((_, n) => runOrder.Add(n.ToString())) .Then(TaskEx.FromResult(20f), TaskAffinity.Exclusive) .Then((_, n) => n + 1) .Then((_, n) => runOrder.Add(n.ToString())) .Finally((_, t) => runOrder.Add("done")) ; await act.StartAsAsync(); CollectionAssert.AreEqual(new string[] { "started", "2", "21", "done" }, runOrder); }