void CalcLazyTotal(object[] k, IAggregator totalAggr) { int i; int dimLen = dimensions.Length; bool matched; var emptyKey = Key.Empty; // avoid getter for performance object[] dpKey; KeyValuePair <object[], IAggregator> dataPoint; if (valuesArr == null || valuesArr.Length != values.Count) { valuesArr = new KeyValuePair <object[], IAggregator> [values.Count]; int j = 0; foreach (var dp in values) { valuesArr[j++] = dp; } } for (int j = 0; j < valuesArr.Length; j++) { dataPoint = valuesArr[j]; dpKey = dataPoint.Key; matched = true; for (i = 0; i < dimLen; i++) { if (emptyKey == k[i]) { continue; } if (!k[i].Equals(dpKey[i])) { matched = false; break; } } if (!matched) { continue; } totalAggr.Merge(dataPoint.Value); } }
private void AggregatorBaseBehaviors(IAggregator aggregator, bool requiresColumns = true) { // Verify ToString returns the aggregator type, which matches the start of the class name string name = aggregator.ToString(); Assert.AreEqual(aggregator.GetType().Name.ToLowerInvariant(), (name + "aggregator").ToLowerInvariant()); // Verify Merge throws if the values are null Verify.Exception <ArgumentNullException>(() => aggregator.Merge(null, null)); // Verify Aggregate throws if the matches or columns are null Verify.Exception <ArgumentNullException>(() => aggregator.Aggregate(null, null, new IUntypedColumn[1] { ColumnFactory.Build(new ColumnDetails("ID", "int", null), 100) })); if (requiresColumns) { ShortSet sample = new ShortSet(100); sample.Or(new ushort[] { 1, 2, 3 }); Verify.Exception <ArgumentException>(() => aggregator.Aggregate(null, sample, null)); } }