示例#1
0
        public static bool EqualsTests(string leftVal, string rightVal)
        {
            var left  = OptionTests.MakeOption(leftVal);
            var right = OptionTests.MakeOption(rightVal);

            return(left.Equals(right));
        }
示例#2
0
 public static string BindTests(string val, bool returnValue)
 {
     return(OptionTests
            .MakeOption(val)
            .Pipe(Option.Bind <string, int>(x => returnValue ? Option.Some(x.Length) : Option.None <int>()))
            .ToString());
 }
示例#3
0
        public static string OrTests(string leftVal, string rightVal)
        {
            var left  = OptionTests.MakeOption(leftVal);
            var right = OptionTests.MakeOption(rightVal);

            return((left || right).ToString());
        }
示例#4
0
 public static string ToEitherRightTests(string val, int rightValue)
 {
     return(OptionTests
            .MakeOption(val)
            .ToEitherRight(rightValue)
            .ToString());
 }
示例#5
0
 public static string WhereTests(string val)
 {
     return((from x in OptionTests.MakeOption(val)
             where x == "B"
             select x.Length)
            .ToString());
 }
示例#6
0
 public static string MapTests(string val)
 {
     return(OptionTests
            .MakeOption(val)
            .Pipe(Option.Map <string, string>(x => x.ToLower()))
            .ToString());
 }
示例#7
0
 public static string FilterTests(string val)
 {
     return(OptionTests
            .MakeOption(val)
            .Pipe(Option.Filter <string>(x => x == "B"))
            .ToString());
 }
示例#8
0
        public static string OfTypeTests(string val, bool wrapValue)
        {
            var innerOption = OptionTests.MakeOption(val);

            return((wrapValue ? innerOption.ToOption() : Option.None <Option <string> >())
                   .Pipe(Option.OfType <Option <string>, OptionSome <string> >())
                   .ToString());
        }
示例#9
0
 public static string MatchTests(string val)
 {
     return(OptionTests
            .MakeOption(val)
            .Pipe(Option.Match <string, string>(
                      x => $"Just: {x}",
                      () => "Nothing")));
 }
示例#10
0
 public static string SelectManyTests(string val, bool returnSome)
 {
     return((from x in OptionTests.MakeOption(val)
             from y in returnSome
                 ? Option.None <bool>()
                 : (x.Length == 0).ToOption()
             select y)
            .ToString());
 }
示例#11
0
 public static string ToStringTests(string val)
 {
     return(OptionTests.MakeOption(val).ToString());
 }
示例#12
0
 public static bool IsEmptyTests(string val)
 {
     return(OptionTests.MakeOption(val).IsEmpty);
 }
示例#13
0
        public static object GetEnumeratorTests(string val)
        {
            var enumerator = ((IEnumerable)OptionTests.MakeOption(val)).GetEnumerator();

            return(enumerator.MoveNext() ? enumerator.Current : null);
        }
示例#14
0
 public static string SelectTests(string val)
 {
     return((from x in OptionTests.MakeOption(val)
             select x.Length)
            .ToString());
 }
示例#15
0
 public static string DefaultWithTests(string val)
 {
     return(OptionTests
            .MakeOption(val)
            .Pipe(Option.DefaultWith("B")));
 }