Exemplo n.º 1
0
        public void And()
        {
            Result <int, Exception> res1 = new Ok <int, Exception>(1);

            Assert.Equal(2, res1.And(new Ok <int, Exception>(2)).Unwrap());
            Assert.Equal(typeof(Err <string, Exception>), res1.And(new Err <string, Exception>(new Exception("this is test."))).GetType());

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

            Assert.Equal(typeof(Err <string, Exception>), res2.And(new Ok <string, Exception>("string value.")).GetType());
            Assert.Equal(typeof(Err <string, Exception>), res2.And(new Err <string, Exception>(new Exception("this is test."))).GetType());
        }