Beispiel #1
0
        public void BindToProperty () {
            var tc = new TestClass();
            var ts = new TestStruct();

            var f = new Future<int>();

            f.Bind(() => tc.Property);

            try {
                f.Bind(() => ts.Property);
                Assert.Fail("Did not throw InvalidOperationException");
            } catch (InvalidOperationException) {
            }

            f.Complete(5);

            Assert.AreEqual(5, tc.Property);
            Assert.AreNotEqual(5, ts.Property);
        }
Beispiel #2
0
 public void CanBindFutureToOtherFuture () {
     var a = new Future<object>();
     var b = new Future<object>();
     b.Bind(a);
     a.Complete(5);
     Assert.AreEqual(5, b.Result);
 }
Beispiel #3
0
 public static Future <C> SelectMany <A, B, C>(this Future <A> m, Func <A, Future <B> > k, Func <A, B, C> f)
 {
     return(m.Bind(a => k(a).Bind <B, C>(b => f(a, b).PureFuture())));
 }
Beispiel #4
0
 public static Future <T> Join <T>(this Future <Future <T> > future)
 {
     return(future.Bind(a => a));
 }
Beispiel #5
0
 public static Future <B> SelectMany <A, B>(this Future <A> m, Func <A, Future <B> > k)
 {
     return(m.Bind(k));
 }