[Test] public void testSequenceDeferred() { var counter = new FutureCounter(); var success1 = new Promise <string>(); var success2 = new Promise <string>(); var failure1 = new Promise <string>(); var failure2 = new Promise <string>(); var suc2seq = Future.Sequence(List <IFuture <string> >(success1, success2)); counter.Bind(suc2seq); suc2seq.OnSuccess(results => { Assert.AreEqual(List("Yay 1!", "Yay 2!"), results); }); counter.Check("before seq succeed/succeed", 0, 0, 0); success1.Succeed("Yay 1!"); success2.Succeed("Yay 2!"); counter.Check("after seq succeed/succeed", 1, 0, 1); IFuture <List <string> > sucfailseq = Future.Sequence(List <IFuture <string> >(success1, failure1)); sucfailseq.OnFailure(cause => { var agg = cause as AggregateException; Assert.NotNull(agg); Assert.AreEqual(1, agg.InnerExceptions.Count); }); counter.Bind(sucfailseq); counter.Check("before seq succeed/fail", 0, 0, 0); failure1.Fail(new Exception("Boo 1!")); counter.Check("after seq succeed/fail", 0, 1, 1); IFuture <List <string> > failsucseq = Future.Sequence(List <IFuture <string> >(failure1, success2)); failsucseq.OnFailure(cause => { var agg = cause as AggregateException; Assert.NotNull(agg); Assert.AreEqual(1, agg.InnerExceptions.Count); }); counter.Bind(failsucseq); counter.Check("after seq fail/succeed", 0, 1, 1); IFuture <List <string> > fail2seq = Future.Sequence(List <IFuture <string> >(failure1, failure2)); fail2seq.OnFailure(cause => { var agg = cause as AggregateException; Assert.NotNull(agg); Assert.AreEqual(2, agg.InnerExceptions.Count); }); counter.Bind(fail2seq); counter.Check("before seq fail/fail", 0, 0, 0); failure2.Fail(new Exception("Boo 2!")); counter.Check("after seq fail/fail", 0, 1, 1); }