private Fact GetAggregateFact(object aggregate, object previous = null) { if (!_aggregateFactMap.TryGetValue(previous ?? aggregate, out var fact)) { throw new InvalidOperationException( $"Fact for aggregate object does not exist. AggregatorTye={_aggregator.GetType()}, FactType={aggregate.GetType()}"); } if (!ReferenceEquals(fact.RawObject, aggregate)) { _aggregateFactMap.Remove(fact.RawObject); fact.RawObject = aggregate; _aggregateFactMap.Add(fact.RawObject, fact); } return(fact); }
private Fact GetAggregateFact(AggregationResult result) { if (!_aggregateFactMap.TryGetValue(result.Previous ?? result.Aggregate, out var fact)) { throw new InvalidOperationException( $"Fact for aggregate object does not exist. AggregatorTye={_aggregator.GetType()}, FactType={result.Aggregate.GetType()}"); } fact.Source = new AggregateFactSource(result.Source); if (!ReferenceEquals(fact.RawObject, result.Aggregate)) { _aggregateFactMap.Remove(fact.RawObject); fact.RawObject = result.Aggregate; _aggregateFactMap.Add(fact.RawObject, fact); } return(fact); }
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)); } }