I want to write a test for my own GroupBy but i have a problem.
The GroupBy method:
Part of my test code:
Func<ProductsList.Product, string> elementSelector = x => x.Name;
Func<ProductsList.Product, int> keySelector = x => x.Ingredients.Count;
Func<int, IEnumerable<string>, KeyValuePair<int, IEnumerable<string>>> resultSelector = (IngredientsCount, ProductList) =>
{
return new KeyValuePair<int, IEnumerable<string>>(IngredientsCount, ProductList);
};
var comparer = new ProductListComparer();
var result = LinqFunctions.GroupBy(products,
x => keySelector(x),
y => elementSelector(y),
(int IngredientsCount, IEnumerable<string> ProductNames) => resultSelector(IngredientsCount, ProductNames),
comparer
);
//rest of the code
}
I get the following error:
error CS0411: The type arguments for method 'LinqFunctions.GroupBy<TSource, TKey, TElement, TResult>(IEnumerable<TSource>, Func<TSource, TKey>, Func<TSource, TElement>, Func<TKey, IEnumerable<TElement>, TResult>, IEqualityComparer<TKey>)' cannot be inferred from the usage. Try specifying the type arguments explicitly.
I tried everything but can't find a solution. Any help please?