public static void LazyFunc_ManyInputs_Simple() { LazyFunc<int, int, int> adder = new LazyFunc<int, int, int>((a, b) => a + b); Assert.Equal(adder.Get(0, 0), 0); Assert.Equal(adder.Get(1, 0), 1); Assert.Equal(adder.Get(0, 1), 1); Assert.Equal(adder.Get(5, 3), 8); Assert.Equal(adder.Get(3, 5), 8); }
public static void LazyFunc_ManyInputs_Simple() { LazyFunc <int, int, int> adder = new LazyFunc <int, int, int>((a, b) => a + b); Assert.Equal(adder.Get(0, 0), 0); Assert.Equal(adder.Get(1, 0), 1); Assert.Equal(adder.Get(0, 1), 1); Assert.Equal(adder.Get(5, 3), 8); Assert.Equal(adder.Get(3, 5), 8); }
public static void LazyFunc_ManyInputs_ThrowingRecursive() { LazyFunc<int, int, int> adder = null; adder = new LazyFunc<int, int, int>((a, b) => adder.Get(b, a)); Assert.Throws<System.InvalidOperationException>(() => adder.Get(0, 0)); Assert.Throws<System.InvalidOperationException>(() => adder.Get(1, 0)); Assert.Throws<System.InvalidOperationException>(() => adder.Get(0, 1)); Assert.Throws<System.InvalidOperationException>(() => adder.Get(5, 3)); Assert.Throws<System.InvalidOperationException>(() => adder.Get(3, 5)); }
public static void LazyFunc_ManyInputs_ThrowingRecursive() { LazyFunc <int, int, int> adder = null; adder = new LazyFunc <int, int, int>((a, b) => adder.Get(b, a)); Assert.Throws <System.InvalidOperationException>(() => adder.Get(0, 0)); Assert.Throws <System.InvalidOperationException>(() => adder.Get(1, 0)); Assert.Throws <System.InvalidOperationException>(() => adder.Get(0, 1)); Assert.Throws <System.InvalidOperationException>(() => adder.Get(5, 3)); Assert.Throws <System.InvalidOperationException>(() => adder.Get(3, 5)); }
public static void LazyFunc_ManyInputs_SafeRecursive() { LazyFunc<int, int, int> adder = null; adder = new LazyFunc<int, int, int>((a, b) => { if (a < b) return adder.Get(b, a); return a + b; }); Assert.Equal(adder.Get(0, 0), 0); Assert.Equal(adder.Get(1, 0), 1); Assert.Equal(adder.Get(0, 1), 1); Assert.Equal(adder.Get(5, 3), 8); Assert.Equal(adder.Get(3, 5), 8); }
public static void LazyFunc_ManyInputs_SafeRecursive() { LazyFunc <int, int, int> adder = null; adder = new LazyFunc <int, int, int>((a, b) => { if (a < b) { return(adder.Get(b, a)); } return(a + b); }); Assert.Equal(adder.Get(0, 0), 0); Assert.Equal(adder.Get(1, 0), 1); Assert.Equal(adder.Get(0, 1), 1); Assert.Equal(adder.Get(5, 3), 8); Assert.Equal(adder.Get(3, 5), 8); }