Exemplo n.º 1
0
 public void Passing_Null_Function__Throws_ArgumentNullException()
 {
     Assert.Throws <ArgumentNullException>(() => {
         Func <string, IAsyncMaybe <bool> > function = null;
         AsyncMaybe.Value("foo").FlatMapAsync(function);
     });
 }
Exemplo n.º 2
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);
    }
Exemplo n.º 3
0
 Maybe_String_Whose_Property_HasValue_Is_True_Flatmapping_Some__Pasing_Null_ResultSelector__ArgumentNullReferenceException_Thrown()
 {
     Assert.Throws <ArgumentNullException>(() => {
         Func <string, string, string> resultSelector = null;
         AsyncMaybe.Value("foo").FlatMapAsync(AsyncMaybe.Value, resultSelector);
     });
 }
Exemplo n.º 4
0
 Maybe_String_Whose_Property_HasValue_Is_True__Pasing_Null_Selector__ArgumentNullReferenceException_Thrown()
 {
     Assert.Throws <ArgumentNullException>(() => {
         Func <string, IAsyncMaybe <string> > selector = null;
         AsyncMaybe.Value("foo").FlatMapAsync(selector);
     });
 }
Exemplo n.º 5
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();
 }
Exemplo n.º 6
0
    ResultSelector_Overload__Flattening_From_String_Maybe_With_value_To_Nullable_Int_Without_Value__Expects_String_Maybe_Without_Value()
    {
        const string input       = "hello";
        int?         nullableInt = null;

        await AsyncMaybe.Value(input)
        .FlatMapAsync(async x => {
            await AssertionUtilities.Delay;
            return(nullableInt);
        }, (x, y) => x.Length + y)
        .AssertNone();
    }
Exemplo n.º 7
0
    Flattening_From_String_Maybe_With_value_To_Nullable_Int_With_Value__Expects_String_Maybe_With_Value()
    {
        const string input       = "hello";
        int?         nullabelInt = 2;

        await AsyncMaybe.Value(input)
        .FlatMapAsync(async x => {
            await AssertionUtilities.Delay;
            return(nullabelInt);
        })
        .AssertValue(nullabelInt.Value);
    }