public void ConcurrentMonad2ErrorTest() { var m1 = new BlockMonad <int>(TestTask1); var m2 = new BlockMonad <string>(TestTask2); var mc = new ConcurrentMonad <int, string>(m1, m2); _Wait(mc); Assert.AreEqual(default((int, string)), mc.Result); Assert.AreEqual(mc.Error.Message, "error 2"); }
public void WaitAllConcurrentMonad2Test() { var m1 = new BlockMonad <int>(TestTask1); var m3 = new BlockMonad <string>(TestTask3); var mc = new WaitAllConcurrentMonad <int, string>(m1, m3); _Wait(mc); Assert.AreEqual(mc.Result.Item1.Result, 10); Assert.AreEqual(mc.Result.Item2.Result, "ok 3"); Assert.IsNull(mc.Error); }
public void BlockMonadTest() { var m1 = new BlockMonad <int>(TestTask1); var m2 = new BlockMonad <string>(TestTask2); _Wait(m1); Assert.IsNull(m1.Error); Assert.AreEqual(m1.Result, 10); _Wait(m2); Assert.IsNull(m2.Result); Assert.AreEqual(m2.Error.Message, "error 2"); }
public void ConcurrentMonad3Test() { var m1 = new BlockMonad <int>(TestTask1); var m3 = new BlockMonad <string>(TestTask3); var m4 = new BlockMonad <bool>(TestTask4); var mc = new ConcurrentMonad <int, string, bool>(m1, m3, m4); _Wait(mc); Assert.AreEqual(mc.Result.Item1, 10); Assert.AreEqual(mc.Result.Item2, "ok 3"); Assert.AreEqual(mc.Result.Item3, true); Assert.IsNull(mc.Error); }
public void WaitAllConcurrentMonad2ErrorTest() { var m1 = new BlockMonad <int>(TestTask1); var m2 = new BlockMonad <string>(TestTask2); var mc = new WaitAllConcurrentMonad <int, string>(m1, m2); _Wait(mc); Assert.IsNull(mc.Error); Assert.AreEqual(10, mc.Result.Item1.Result); Assert.IsNull(mc.Result.Item1.Error); Assert.IsNull(mc.Result.Item2.Result); Assert.AreEqual(mc.Result.Item2.Error.Message, "error 2"); }
public void PoolThreadedMonadTest() { int t = 0; var m1 = new PoolThreadedMonad <int>(() => { System.Threading.Thread.Sleep(500); return(3 * t); }); var m2 = new BlockMonad <int>(r => { r.Accept(2); return(Coroutine.Sleep(0.1f)); }).Then(res => t = res); var m3 = Monad.WhenAll(m1, m2); _Wait(m3); Assert.AreEqual(6, m3.Result.Item1); }