public void OnOkTest_ThrowEx() { bool a = false, b = false; var tInitial = new Task(() => { a = true; throw new Exception("ex A"); }); var tThen = tInitial.OnOk(() => { b = true; }); try { tInitial.Start(); tThen.Wait(); Assert.Fail(); } catch (AggregateException ex) { Assert.AreEqual(1, ex.InnerExceptions.Count); Assert.AreEqual("ex A", ex.InnerExceptions[0].Message); Assert.IsTrue(a); Assert.IsFalse(b); } }
public void OnOkOrError_ThrowEx() { bool a = false, b = false, c = false; var tInitial = new Task(() => { a = true; throw new Exception("ex A"); }); var tThen = tInitial.OnOk(() => { b = true; }); var tOnFinally = tThen.OnOkOrError(t => { c = true; }); try { tInitial.Start(); tOnFinally.Wait(); Assert.Fail(); } catch (AggregateException) { Assert.IsTrue(a); Assert.IsFalse(b); Assert.IsTrue(c); } }