예제 #1
0
        public void AlternativeFailureYieldsSecond()
        {
            var expected = "second".AsEither <String, Exception>();

            var actual = Either <String, Exception> .CreateError(new Exception("boo"))
                         .Alternatively("second".AsEither <String, Exception>());

            Assert.Equal(expected, actual);
        }
예제 #2
0
        public void MapErrorSameTypes()
        {
            var expected = "NewError";

            var initial = Either <string, string> .CreateError("Error");

            var result = initial.MapError(_ => expected);

            Assert.True(result.IsError);
            Assert.False(result.IsSuccess);

            Assert.Equal(expected, result.AsError.Value);
        }
예제 #3
0
        public void MapErrorSameFinalType()
        {
            var expected = DateTime.Now;

            var initial = Either <DateTime, string> .CreateError("Error");

            var result = initial.MapError(_ => expected);

            Assert.True(result.IsError);
            Assert.False(result.IsSuccess);

            Assert.Equal(expected, result.AsError.Value);
        }