public void OptionExistsWhenTrue() { bool expected = true; Option <int> optionValue = 36; bool result = OptionModule.Exists(_isEven, optionValue); Assert.AreEqual(expected, result); }
public void OptionExistsWhenNone() { bool expected = false; Option <int> optionValue = Option <int> .None(); bool result = OptionModule.Exists(_isEven, optionValue); Assert.AreEqual(expected, result); }
/// <summary> /// Returns true if the <paramref name="option"/> <see cref="Option{T}.IsSome"/> and the <paramref name="predicate"/> return true when applied it. /// Otherwise, returns false. /// </summary> /// <typeparam name="T">The type of the option value.</typeparam> /// <param name="predicate">A function that evaluates whether the value contained in the option is valid or not.</param> /// <param name="option">The input option.</param> /// <returns> /// Returns true if the <paramref name="option"/> <see cref="Option{T}.IsSome"/> and the <paramref name="predicate"/> return true when applied it. /// Otherwise, returns false. /// </returns> public static bool Exists <T>(this Option <T> option, Func <T, bool> predicate) => OptionModule.Exists(predicate, option);