If I want to initialize a list of groupings, can I do this inline?
Update with context
I already know I cannot initialize an interface, but is there already an implementation built into dotnet?
I don't want to create my own implementation, because I am trying to refactor an existing private method into its own class which is public, thus I need to pass parameters in for unit testing.
void MyMethod(IList<IGrouping<int, MyObject>> objGroupings)
Currently I have resorted to initializing a list, then grouping by a key:
var fooList = new List<MyObject>
{
new MyObject{ foo = 5 },
new MyObject{ foo = 5 },
new MyObject{ foo = 5 },
new MyObject{ foo = 2 },
new MyObject{ foo = 2 }
};
var fooGrouping = fooList.GroupBy(o => o.foo).ToList();