public void BindMonadTest() { var m1 = new SimpleMonad <string>("12345"); // m1 will output 12345 var m2 = m1.Then(s => new ParseStringMonad(s)); _Wait(m2); Assert.AreEqual(m2.Result, 12345); }
public void BindMonadFirstErrorTest() { var m1 = new SimpleMonad <string>(new System.Exception("error 1")); // m1 will failed with this error var m2 = m1.Then(s => new ParseStringMonad(s)); _Wait(m2); Assert.IsNotNull(m2.Error); Assert.AreEqual(m2.Error.Message, "error 1"); }
public void BindMonadSecondErrorTest() { var m1 = new SimpleMonad <string>("abcde"); // m1 output is not number var m2 = m1.Then(s => new ParseStringMonad(s)); _Wait(m2); Assert.IsNotNull(m2.Error); Assert.IsInstanceOf(typeof(FormatException), m2.Error); }
public void BindMonadSimpleFuncTest2() { bool called = false; System.Action <string> setSpriteToImage = (string path) => { called = true; }; var m1 = new SimpleMonad <string>("icon.png"); var m2 = m1.Then(setSpriteToImage); _Wait(m2); Assert.IsTrue(called); }