public void Eagerly_Validates_Element_Plain_Key_Task_Element_Comparer() { Assert.Throws <ArgumentNullException>(() => { IAsyncLookup <int, int> iter = AsyncEnumerable.ToLookup(AsyncEnumerable.Empty <int>(), k => k, (Func <int, Task <int> >)null, new IntComparer()); }); }
public void Eagerly_Validates_Source_Task_Key_Plain_Element_Comparer() { Assert.Throws <ArgumentNullException>(() => { IAsyncLookup <int, int> iter = AsyncEnumerable.ToLookup((IAsyncEnumerable <int>)null, k => Task.FromResult(k), k => k, new IntComparer()); }); }
public void Eagerly_Validates_Key_Value_Key_No_Element_No_Comparer() { Assert.Throws <ArgumentNullException>(() => { IAsyncLookup <int, int> iter = AsyncEnumerable.ToLookup(AsyncEnumerable.Empty <int>(), (Func <int, ValueTask <int> >)null); }); }
public void Eagerly_Validates_Key_Plain_Key_Task_Element_No_Comparer() { Assert.Throws <ArgumentNullException>(() => { IAsyncLookup <int, int> iter = AsyncEnumerable.ToLookup(AsyncEnumerable.Empty <int>(), (Func <int, int>)null, k => Task.FromResult(k)); }); }
public void Eagerly_Validates_Source_Value_Key_Value_Element_Comparer() { Assert.Throws <ArgumentNullException>(() => { IAsyncLookup <int, int> iter = AsyncEnumerable.ToLookup((IAsyncEnumerable <int>)null, k => new ValueTask <int>(k), k => new ValueTask <int>(k), new IntComparer()); }); }
public void Eagerly_Validates_Source_Plain_Key_Plain_Element_No_Comparer() { Assert.Throws <ArgumentNullException>(() => { IAsyncLookup <int, int> iter = AsyncEnumerable.ToLookup((IAsyncEnumerable <int>)null, k => k, k => k); }); }
public async Task Empty_Sequence_Produces_Empty_Lookup_Task_Key_No_Element_No_Comparer() { var source = AsyncEnumerable.Empty <int>(); IAsyncLookup <int, int> target = source.ToLookup(k => Task.FromResult(k)); Assert.Equal(0, await target.GetCount()); }
public async Task Multi_Sequence_Basic() { var source = Enumerable.Range(0, 20).AsAsyncEnumerable(); IAsyncLookup <int, int> target = source.ToLookup(k => k % 8); Assert.Equal(8, await target.GetCount()); }
public async Task Empty_Sequence_Produces_Empty_Lookup_Value_Key_Value_Element_Comparer() { var source = AsyncEnumerable.Empty <int>(); IAsyncLookup <int, int> target = source.ToLookup(k => new ValueTask <int>(k), k => new ValueTask <int>(k), new IntComparer()); Assert.Equal(0, await target.GetCount()); }
public async Task Multi_Sequence_With_Comparer() { var source = Enumerable.Range(0, 3).AsAsyncEnumerable(); IAsyncLookup <int, int> target = source.ToLookup(k => k % 8, new ModComparer()); Assert.True(await target.ContainsKey(2)); Assert.False(await target.ContainsKey(3)); }
/// <summary> /// Count the number of key-element sequence pairs in the current lookup. /// </summary> /// <typeparam name="TKey">The type of the keys.</typeparam> /// <typeparam name="TElement">The type of the grouped elements.</typeparam> /// <param name="lookup">The current lookup.</param> /// <returns> /// A value correspoding to the number of key-element sequence pairs in the current lookup. /// </returns> public static Task <ulong> CountAsync <TKey, TElement>(this IAsyncLookup <TKey, TElement> lookup) { return(lookup.CountAsync(CancellationToken.None)); }
/// <summary> /// Determine whether the current lookup contains a given key. /// </summary> /// <typeparam name="TKey">The type of the keys.</typeparam> /// <typeparam name="TElement">The type of the grouped elements.</typeparam> /// <param name="lookup">The current lookup.</param> /// <param name="key">An object of the key type.</param> /// <returns> /// A value indicating whether or not the current lookup contains the given key. /// </returns> public static Task <bool> ContainsAsync <TKey, TElement>(this IAsyncLookup <TKey, TElement> lookup, TKey key) { return(lookup.ContainsAsync(key, CancellationToken.None)); }