Exemplo n.º 1
0
        public static bool EqualsTests(string leftVal, string rightVal)
        {
            var left  = OptionTests.MakeOption(leftVal);
            var right = OptionTests.MakeOption(rightVal);

            return(left.Equals(right));
        }
Exemplo n.º 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());
 }
Exemplo n.º 3
0
        public static string OrTests(string leftVal, string rightVal)
        {
            var left  = OptionTests.MakeOption(leftVal);
            var right = OptionTests.MakeOption(rightVal);

            return((left || right).ToString());
        }
Exemplo n.º 4
0
 public static string ToEitherRightTests(string val, int rightValue)
 {
     return(OptionTests
            .MakeOption(val)
            .ToEitherRight(rightValue)
            .ToString());
 }
Exemplo n.º 5
0
 public static string WhereTests(string val)
 {
     return((from x in OptionTests.MakeOption(val)
             where x == "B"
             select x.Length)
            .ToString());
 }
Exemplo n.º 6
0
 public static string MapTests(string val)
 {
     return(OptionTests
            .MakeOption(val)
            .Pipe(Option.Map <string, string>(x => x.ToLower()))
            .ToString());
 }
Exemplo n.º 7
0
 public static string FilterTests(string val)
 {
     return(OptionTests
            .MakeOption(val)
            .Pipe(Option.Filter <string>(x => x == "B"))
            .ToString());
 }
Exemplo n.º 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());
        }
Exemplo n.º 9
0
 public static string MatchTests(string val)
 {
     return(OptionTests
            .MakeOption(val)
            .Pipe(Option.Match <string, string>(
                      x => $"Just: {x}",
                      () => "Nothing")));
 }
Exemplo n.º 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());
 }
Exemplo n.º 11
0
 public static string ToStringTests(string val)
 {
     return(OptionTests.MakeOption(val).ToString());
 }
Exemplo n.º 12
0
 public static bool IsEmptyTests(string val)
 {
     return(OptionTests.MakeOption(val).IsEmpty);
 }
Exemplo n.º 13
0
        public static object GetEnumeratorTests(string val)
        {
            var enumerator = ((IEnumerable)OptionTests.MakeOption(val)).GetEnumerator();

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