示例#1
0
        public void EitherExistsLeftFalseWhenRight()
        {
            bool expected = false;
            Either <string, int> either = 10;
            bool result =
                EitherModule.ExistsLeft(
                    right => right == "Hello"
                    , either);

            Assert.AreEqual(expected, result);
        }
示例#2
0
        public void EitherExistsLeftTrueWhenLeft()
        {
            bool expected = true;
            Either <string, int> either = "Hello";
            bool result =
                EitherModule.ExistsLeft(
                    right => right == "Hello"
                    , either);

            Assert.AreEqual(expected, result);
        }
示例#3
0
 /// <summary>
 ///  Returns true when <paramref name="either"/> <see cref="Either{TLeft, TRight}.IsLeft"/> and given <paramref name="predicate"/> function applied to <paramref name="either"/> return true.
 ///  Otherwise, returns false.
 /// </summary>
 /// <typeparam name="TLeft">The type of the left value.</typeparam>
 /// <typeparam name="TRight">The type of the right value.</typeparam>
 /// <param name="predicate">A function that evaluates whether the left value contained in the option is valid or not.</param>
 /// <param name="either">the input either.</param>
 /// <returns>
 /// Returns true if the given predicate functions return true when applied to either value.
 /// </returns>
 public static bool ExistsLeft <TLeft, TRight>(this Either <TLeft, TRight> either, Func <TLeft, bool> predicate)
 => EitherModule.ExistsLeft(predicate, either);