예제 #1
0
    ResultSelector_Overload__Flattening_From_String_Maybe_With_value_To_String_Maybe_Without_Value__Expects_String_Maybe_Without_Value()
    {
        const string input = "hello";

        await AsyncMaybe.Value(input)
        .FlatMapAsync(x => AsyncMaybe.None <string>(), (x, y) => x.Length + y.Length);
    }
예제 #2
0
 Flattening_From_String_Maybe_With_value_To_String_Maybe_Without_Value__Expects_String_Maybe_Without_Value()
 {
     const string input = "hello";
     await AsyncMaybe.Value(input)
     .FlatMapAsync(x => AsyncMaybe.None <int>())
     .AssertNone();
 }
예제 #3
0
        public static AsyncMaybe <T> Flatten <T>(this AsyncMaybe <Maybe <T> > source)
        {
            var t = source.Match <AsyncMaybe <T> >(
                some: outerValue => new AsyncMaybe <T>(Task.FromResult <Maybe <T> >(outerValue)),
                none: none => AsyncMaybe <T> .None()
                );

            return(t.ToAsyncMaybe());
        }
예제 #4
0
 ResultSelector_Overload__Flattening_From_String_Maybe_Without_value_To_Nullable_Int_With_Value__Expects_String_Maybe_Without_Value()
 {
     int?nullableInt = 2;
     await AsyncMaybe.None <string>()
     .FlatMapAsync(async x => {
         await AssertionUtilities.Delay;
         return(nullableInt);
     }, (x, y) => x.Length + y)
     .AssertNone();
 }
예제 #5
0
 ResultSelector_Overload__Flattening_From_String_Maybe_Without_value_To_String_Maybe_Without_Value__Expects_String_Maybe_Without_Value()
 {
     await AsyncMaybe.None <string>()
     .FlatMapAsync(x => AsyncMaybe.None <string>())
     .AssertNone();
 }
 public static AsyncMaybe <TResult> FlatMapAsync <T, TResult>(
     this AsyncMaybe <T> source,
     [NotNull] Func <T, Task <AsyncMaybe <TResult> > > mapper)
 {
     return(source.Match(mapper, none => AsyncMaybe <TResult> .None()).ToAsyncMaybe());
 }
예제 #7
0
 public static AsyncMaybe <T> ToAsyncMaybe <T>(this None none)
 {
     return(AsyncMaybe <T> .None());
 }