示例#1
0
        public void AsOptionForError_IsNoneAndCallbackFired()
        {
            var expectedError = "fail";

            Either <int, string> either = expectedError;

            bool wasCalled = false;
            var  option    = either.AsOption(e => { wasCalled = true; });

            Assert.True(wasCalled);
            Assert.False(option.IsSome);
        }
示例#2
0
        public void AsOptionForSuccess_CarriesValue()
        {
            var expectedSucess = 42;

            Either <int, string> either = expectedSucess;

            bool wasCalled = false;
            var  option    = either.AsOption(e => { wasCalled = true; });

            Assert.False(wasCalled);
            Assert.True(option.IsSome);
            Assert.Equal(expectedSucess, option.ForceValue());
        }