public void WhenUnfulfilled() { var f = Future.unfulfilled <int>(); var result = 0; f.nowAndOnComplete(iOpt => result += iOpt.fold(-1, _ => _)); result.shouldEqual(-1, "it should run the function once"); }
public void NotCompletedThenSignal() { var t = Future.unfulfilled <Unit>().delayUntilSignal(); t._1.shouldNotBeCompleted(); t._2(); t._1.shouldNotBeCompleted(); }
public void WhenUnfulfilled() { var f = Future.unfulfilled <int>(); var result = 0; f.onComplete(i => result = i); result.shouldEqual(0, "it should not run the function"); }
public void WhenNoCompleted() { new[] { Future.unfulfilled <int>(), Future.unfulfilled <int>(), Future.unfulfilled <int>(), Future.unfulfilled <int>() }.firstOf().value.shouldEqual(F.none <int>()); }
public void WhenHasCompleted() { new[] { Future.unfulfilled <int>(), Future.unfulfilled <int>(), Future.successful(1), Future.unfulfilled <int>(), Future.unfulfilled <int>() }.firstOf().value.get.shouldEqual(1); }
public void WhenEitherSideUnfulfilled() { foreach (var t in new[] { F.t("X-O", Future.unfulfilled <int>(), Future.successful(1)), F.t("O-X", Future.successful(1), Future.unfulfilled <int>()) }) { t.ua((name, fa, fb) => fa.zip(fb).shouldBeOfUnfulfilledType(name)); } }
public void Equals() { Promise <int> asyncP; var asyncF = Future <int> .async(out asyncP); var unfullfilled = Future.unfulfilled <int>(); var completed = Future.successful(3); shouldNotEqualSymmetrical(unfullfilled, completed); shouldBeIdentical(unfullfilled, asyncF); shouldNotEqualSymmetrical(asyncF, completed); asyncP.complete(3); shouldNotEqualSymmetrical(unfullfilled, asyncF); shouldBeIdentical(asyncF, completed); }
public void NotCompleteToNotComplete() { Future.unfulfilled <int>().collect(i => F.none <int>()).shouldNotBeCompleted(); Future.unfulfilled <int>().collect(F.some).shouldNotBeCompleted(); }
public void NotCompleteToNotComplete() { Future.unfulfilled <int>().filter(i => false).shouldNotBeCompleted(); Future.unfulfilled <int>().filter(i => true).shouldNotBeCompleted(); }
public static IEnumerable <Future <A> > addUnfulfilled <A>(this IEnumerable <Future <A> > futures) { return(futures.Concat(Future.unfulfilled <A>().Yield())); }