public static RemoteGroupingResult Run(IEnumerable<IRemoteGroup> flatGroups, int groupCount, SummaryInfo[] totalSummary, SummaryInfo[] groupSummary) { var accessor = new RemoteGroupAccessor(); List<Group> hierGroups = null; if(groupCount > 0) { hierGroups = new GroupHelper<IRemoteGroup>(accessor).Group( flatGroups, Enumerable.Range(0, groupCount).Select(i => new GroupingInfo { Selector = "K" + i }).ToArray() ); } IEnumerable dataToAggregate = hierGroups; if(dataToAggregate == null) dataToAggregate = flatGroups; var transformedTotalSummary = TransformSummary(totalSummary, "T"); var transformedGroupSummary = TransformSummary(groupSummary, "G"); transformedTotalSummary.Add(new SummaryInfo { SummaryType = "remoteCount" }); var totals = new AggregateCalculator<IRemoteGroup>(dataToAggregate, accessor, transformedTotalSummary, transformedGroupSummary).Run(); var totalCount = (int)totals.Last(); totals = totals.Take(totals.Length - 1).ToArray(); if(totals.Length < 1) totals = null; return new RemoteGroupingResult { Groups = hierGroups, Totals = totals, TotalCount = totalCount }; }
public void RemoteGroupClass() { var group = new RemoteGroup <object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object, object>(); var type = group.GetType().GetTypeInfo(); var accessor = new RemoteGroupAccessor(); var prefixes = new Dictionary <string, int> { ["K"] = 8, ["T"] = 8, ["G"] = 8 }; foreach (var prefix in prefixes.Keys) { for (var index = 0; index < prefixes[prefix]; index++) { var value = new Object(); type.GetDeclaredField(prefix + index).SetValue(group, value); Assert.Same(value, accessor.Read(group, prefix + index)); } } }