public void OptionCountWhenSome() { Option <int> optionValue = 35; int result = OptionModule.Count(optionValue); Assert.AreEqual(1, result); }
public void OptionCountWhenNone() { Option <int> optionValue = Option <int> .None(); int result = OptionModule.Count(optionValue); Assert.AreEqual(0, result); }
/// <summary> /// Evaluates a <see cref="Option{T}.Match{TResult}(Func{T, TResult}, Func{TResult})"/> that returns one when <see cref="Option{T}.IsSome"/>, otherwise returns 0 /// </summary> /// <typeparam name="T">The type of the option value.</typeparam> /// <param name="option">The input option.</param> /// <returns>Returns one if the option <see cref="Option{T}.IsSome"/>, otherwise returns zero.</returns> public static int Count <T>(this Option <T> option) => OptionModule.Count(option);