Ejemplo n.º 1
0
        public void ShouldNotMapOverAnErr()
        {
            var result = new Err <int>("Value not Found");
            var newRes = result.Map(i => i + 1);

            Assert.IsInstanceOf <Err <int> >(newRes);
            Assert.IsNotNull(newRes.ErrorMessage);
            Assert.AreEqual(default(int), newRes.Value);
        }
Ejemplo n.º 2
0
        public void Map()
        {
            Result <int, Exception> res1 = new Ok <int, Exception>(1);

            Assert.Equal(2, res1.Map(x => x + 1).Unwrap());

            Result <int, Exception> res2 = new Err <int, Exception>(new Exception("this is test."));

            Assert.Equal(typeof(Err <string, Exception>), res2.Map(x => $"{x + 1}").GetType());
        }