예제 #1
0
        public void OptionAsEnumerableWhenSome()
        {
            Option <int>      optionValue = 35;
            IEnumerable <int> result      = OptionModule.AsEnumerable(optionValue);

            Assert.AreEqual(1, result.Count());
        }
예제 #2
0
        public void OptionAsEnumerableWhenNone()
        {
            Option <int> optionValue = Option <int> .None();

            IEnumerable <int> result = OptionModule.AsEnumerable(optionValue);

            Assert.AreEqual(0, result.Count());
        }
예제 #3
0
 /// <summary>
 /// Convert the <see cref="Option{T}"/> to an <see cref="IEnumerable{T}"/> of length 0 or 1.
 /// </summary>
 /// <typeparam name="T">The type of the option value.</typeparam>
 /// <param name="option">the input option.</param>
 /// <returns>Returns an <see cref="IEnumerable{T}"/> with a single element when <see cref="Option{T}.IsSome"/>. Otherwise returns an <see cref="CollectionModule.Empty{T}"/>.</returns>
 public static IEnumerable <T> AsEnumerable <T>(this Option <T> option)
 => OptionModule.AsEnumerable(option);