Пример #1
0
        public void MapTest()
        {
            Either <int, Exception>    i    = 404;
            Either <int, Exception>    e    = new ArgumentException("Hi");
            Either <double, Exception> out1 = i.MapLeft(x => x * 0.5);
            Either <double, Exception> out2 = e.MapLeft(x => x * 0.5);

            Assert.AreEqual(202.0, out1.Value);
            Assert.AreEqual(e.Value, out2.Value);
            Either <int, string> out3 = i.MapRight(x => x.Message);
            Either <int, string> out4 = e.MapRight(x => x.Message);

            Assert.AreEqual(404, out3.Value);
            Assert.AreEqual("Hi", out4.Value);
        }