public void GroupingOnDoubleKeyWorks() { var source = new List <IDictionary <string, object> > { new Dictionary <string, object> { { "Id", 1 }, { "Type", "A" }, { "Size", 1 } }, new Dictionary <string, object> { { "Id", 1 }, { "Type", "A" }, { "Size", 2 } }, new Dictionary <string, object> { { "Id", 1 }, { "Type", "B" }, { "Size", 3 } }, new Dictionary <string, object> { { "Id", 1 }, { "Type", "B" }, { "Size", 4 } }, new Dictionary <string, object> { { "Id", 2 }, { "Type", "A" }, { "Size", 5 } }, new Dictionary <string, object> { { "Id", 2 }, { "Type", "A" }, { "Size", 6 } }, new Dictionary <string, object> { { "Id", 2 }, { "Type", "B" }, { "Size", 7 } }, new Dictionary <string, object> { { "Id", 2 }, { "Type", "B" }, { "Size", 8 } }, }; var target = new GroupingHandler("Id", "Type"); var actual = target.Group(source).ToList(); Assert.AreEqual(4, actual.Count); }
private Dictionary <PSMElement, List <EvolutionChange> > GroupChanges(GroupingHandler groupBy) { IEnumerable <IGrouping <PSMElement, EvolutionChange> > grouped; if (groupBy != null) { grouped = this.GroupBy(change => groupBy(change)); } else { grouped = this.GroupBy(change => change.Element); } Dictionary <PSMElement, List <EvolutionChange> > result = new Dictionary <PSMElement, List <EvolutionChange> >(); foreach (IGrouping <PSMElement, EvolutionChange> grouping in grouped) { result[grouping.Key] = grouping.ToList(); } return(result); }