Example #1
0
        public void Either3_Fold()
        {
            Action a = () => {};
            Either <Action, object, string> e = Either <Action, object, string> .A(a);

            Assert.AreEqual(a, e.Fold(v => v, v => null, v => null));

            e = Either <Action, object, string> .C("foo");

            Assert.AreEqual("foo", e.Fold(v => null, v => null, v => v));
        }
Example #2
0
        public void Either3_Fold_c_Null()
        {
            Func <Action, int> a = x => 42;
            Func <object, int> b = x => Convert.ToInt32(x);
            Func <string, int> c = null;

            var e = Either <Action, object, string> .A(() => {});

            AssertException <ArgumentNullException> (() => e.Fold(a, b, c));

            e = Either <Action, object, string> .B(new object());

            AssertException <ArgumentNullException> (() => e.Fold(a, b, c));

            e = Either <Action, object, string> .C("foo");

            AssertException <ArgumentNullException> (() => e.Fold(a, b, c));
        }
Example #3
0
        public void Either4_Fold_d_Null()
        {
            Func <Action, int> a = x => 42;
            Func <object, int> b = x => Convert.ToInt32(x);
            Func <string, int> c = x => Convert.ToInt32(x);
            Func <Type, int>   d = null;

            var e = Either <Action, object, string, Type> .A(() => {});

            AssertException <ArgumentNullException> (() => e.Fold(a, b, c, d));

            e = Either <Action, object, string, Type> .B(new object());

            AssertException <ArgumentNullException> (() => e.Fold(a, b, c, d));

            e = Either <Action, object, string, Type> .C("foo");

            AssertException <ArgumentNullException> (() => e.Fold(a, b, c, d));

            e = Either <Action, object, string, Type> .D(typeof(object));

            AssertException <ArgumentNullException> (() => e.Fold(a, b, c, d));
        }
Example #4
0
 protected override Either <Action, object, string, Type> CreateValueY()
 {
     return(Either <Action, object, string, Type> .C("y"));
 }
Example #5
0
 protected override Either <Action, object, string> CreateValueZ()
 {
     return(Either <Action, object, string> .C("z"));
 }
Example #6
0
 public void Either4_C_ValueNull()
 {
     Either <Action, object, string, Type> .C(null);
 }
Example #7
0
 public void Either3_C_ValueNull()
 {
     Either <Action, object, string> .C(null);
 }