Exemple #1
0
        public void Or()
        {
            Result <int, Exception> res1 = new Ok <int, Exception>(1);

            Assert.Equal(1, res1.Or(new Ok <int, Exception>(2)).Unwrap());
            Assert.Equal(1, res1.Or(new Err <int, Exception>(new Exception("this is test."))).Unwrap());

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

            Assert.Equal(2, res2.Or(new Ok <int, Exception>(2)).Unwrap());
            Assert.Equal(typeof(Err <int, Exception>), res2.Or(new Err <int, Exception>(new Exception("this is test."))).GetType());
        }