public void IntFailureThroughPromise() { bool called = false; m_promise.FulfillError(new Exception()); m_future.Recover((e) => { called = true; }); Assert.That(called); }
public static IFuture <K> Recover <T, K, W>(this IFuture <T> me, Func <W, K> recoverFunc) // where T:K { InnerFuture other = new InnerFuture(); me.Recover((W e) => { other.Set(recoverFunc(e)); }); me.Map((val) => { other.Set(val); }); return(new FutureWrapper <K>(other)); }
public void IntFutureFailuer() { bool called = false; IFuture <int> success = Future.Failure <int>(new Exception()); success.Recover((e) => { called = true; }); Assert.That(called); }
public static IFuture <K> FlatRecover <T, K, W>(this IFuture <T> me, Func <W, IFuture <K> > recoverFunc) where T : K { InnerFuture other = new InnerFuture(); me.Recover((W e) => { var future = recoverFunc(e); future.Map((x) => other.Set(x)); future.Recover((e2) => other.FlushErrorRecover(e2)); }); me.Recover((object e) => { if (!(e is W)) { other.FlushErrorRecover(e); } }); me.Map((val) => { other.Set(val); }); return(new FutureWrapper <K>(other)); }
public void IntFailureThroughPromiseFlatMapCompoundJustOnce() { int callCount = 0; IPromise <int> promisse2 = new Promise <int>(); m_future.Map((i) => promisse2.FulfillError(new Exception())); m_promise.Fulfill(32); m_future = m_future.FlatMap((i) => promisse2.Future); m_future.Recover((e) => ++ callCount); Assert.AreEqual(1, callCount); }
public void IntFailureThroughPromiseFlatMapCompound() { bool called = false; IPromise <int> promisse2 = new Promise <int>(); m_future.Map((i) => promisse2.FulfillError(new Exception())); m_promise.Fulfill(32); m_future = m_future.FlatMap((i) => promisse2.Future); m_future.Recover((e) => { called = true; }); Assert.That(called); }
public static IFuture <K> Recover <T, K>(this IFuture <T> me, Func <System.Exception, K> recoverFunc) //where T:K { return(me.Recover <T, K, Exception>(recoverFunc)); }