Example #1
0
        public void EitherExistsRightFalseWhenLeft()
        {
            bool expected = false;
            Either <string, int> either = "Hello";
            bool result =
                EitherModule.ExistsRight(
                    left => left == 10
                    , either);

            Assert.AreEqual(expected, result);
        }
Example #2
0
        public void EitherExistsRightTrueWhenRight()
        {
            bool expected = true;
            Either <string, int> either = 10;
            bool result =
                EitherModule.ExistsRight(
                    left => left == 10
                    , either);

            Assert.AreEqual(expected, result);
        }
Example #3
0
 /// <summary>
 ///  Returns true when <paramref name="either"/> <see cref="Either{TLeft, TRight}.IsRight"/> 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 right 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 ExistsRight <TLeft, TRight>(this Either <TLeft, TRight> either, Func <TRight, bool> predicate)
 => EitherModule.ExistsRight(predicate, either);