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)); }
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)); }
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)); }
protected override Either <Action, object, string, Type> CreateValueY() { return(Either <Action, object, string, Type> .C("y")); }
protected override Either <Action, object, string> CreateValueZ() { return(Either <Action, object, string> .C("z")); }
public void Either4_C_ValueNull() { Either <Action, object, string, Type> .C(null); }
public void Either3_C_ValueNull() { Either <Action, object, string> .C(null); }