public void IntegrationTest_WithoutFiltersAndUsingNamedTrackers_AggreagetedResultsMatch() { Configurator.Initialize( new Settings { Persister = new PersistToMongo("mongodb://localhost:27017/Graphene", _fakeLogger), ReportGenerator = new MongoReportGenerator("mongodb://localhost:27017/Graphene", _fakeLogger) } ); Container <TrackerWithCountProperties> .Increment(t => t.ElderlyCount, 10); Container <TrackerWithCountProperties> .Increment(t => t.KidsCount, 5); Container <TrackerWithCountProperties> .Increment(t => t.ElderlyCount, 2); Configurator.ShutDown(); AggregationResults <TrackerWithCountProperties> report = Container <TrackerWithCountProperties> .Report(DateTime.UtcNow.Subtract(new TimeSpan(1, 0, 0)), DateTime.UtcNow.Add(new TimeSpan(1, 0, 0))); Assert.IsTrue(report.Results.Count() >= 1); Assert.IsTrue(report.Results[0].Tracker.ElderlyCount >= 12); Assert.IsTrue(report.Results[0].Tracker.KidsCount >= 5); }
IntegrationTest_GivenFiltersAndNamedTrackers_AggreagetedResultsMatchForPartialFiltersWithMultipleRecordsDefault () { var filter1 = new CustomerFilter { Environment_ServerName = "Env1", Gender = "M", State = "CA", StoreID = Guid.NewGuid().ToString("D") }; Configurator.Initialize( new Settings { Persister = new PersistToMongo("mongodb://localhost:27017/Graphene", _fakeLogger), ReportGenerator = new MongoReportGenerator("mongodb://localhost:27017/Graphene", _fakeLogger) } ); Container <CustomerVisitTracker> .Where(filter1).IncrementBy(10); Configurator.ShutDown(); AggregationResults <CustomerVisitTracker> report = Container <CustomerVisitTracker> .Where(new CustomerFilter { Gender = "M", }).Report(DateTime.UtcNow.Subtract(new TimeSpan(5000, 1, 0, 0)), DateTime.UtcNow.Add(new TimeSpan(1, 0, 0))); Assert.IsTrue(report.Results.Count() >= 1); Assert.AreEqual(ReportResolution.Year, report.Resolution); }
public void IntegrationTest_GivenFilters_AggreagetedResultsMatch() { var filter1 = new CustomerFilter { Environment_ServerName = "Env1", Gender = "M", State = "CA", StoreID = Guid.NewGuid().ToString("D") }; Configurator.Initialize( new Settings { Persister = new PersistToMongo("mongodb://localhost:27017/Graphene", _fakeLogger), ReportGenerator = new MongoReportGenerator("mongodb://localhost:27017/Graphene", _fakeLogger) } ); Container <CustomerVisitTracker> .Where(filter1).IncrementBy(10); Configurator.ShutDown(); AggregationResults <CustomerVisitTracker> report = Container <CustomerVisitTracker> .Where(filter1) .Report(DateTime.UtcNow.Subtract(new TimeSpan(1, 0, 0)), DateTime.UtcNow.Add(new TimeSpan(1, 0, 0))); Assert.IsTrue(report.Results.Any()); Assert.AreEqual(1, report.Results[0].Occurrence); Assert.AreEqual(10, report.Results[0].Total); }
private void HandleAggregateResult(IExecutionContext context, AggregationResults result, Tuple leftTuple, IAggregate aggregate) { Fact aggregateFact = GetAggregateFact(context, aggregate); switch (result) { case AggregationResults.Added: PropagateAggregateAssert(context, leftTuple, aggregateFact); break; case AggregationResults.Modified: PropagateAggregateUpdate(context, leftTuple, aggregateFact); break; case AggregationResults.Removed: PropagateAggregateRetract(context, leftTuple, aggregateFact); break; } }
public IEnumerable <Tuple <Alternative, int> > GetRangedAlternatives() { //var alternativeCount = Alternatives.Count; //var alternatives = Alternatives.OrderBy(x => x.AlternativeId).ToList(); //for (int i = 0; i < alternativeCount; i++) //{ // var alternative = alternatives[i]; // foreach (var aggregation in AggregationResults) // { // var aggregationPlaces = aggregation.Items.OrderByDescending(x => x.Aggregation).Select((x, index) => new { x.AlternativeId, index }); // } //} return(AggregationResults.SelectMany(result => result.Items.OrderByDescending(item => item.Aggregation).Select((x, index) => new { x.AlternativeId, Index = index })) .Where(x => x.Index == 0) .GroupBy(x => x.AlternativeId) .OrderByDescending(x => x.Count()).Select(x => new Tuple <Alternative, int>(Alternatives.Single(alternative => alternative.AlternativeId == x.Key), x.Count())).ToList()); }
public void IntegrationTest_GivenFiltersAndNamedTrackers_AggreagetedResultsMatchForPartialFilters() { string storeId = Guid.NewGuid().ToString("D"); var filter1 = new CustomerFilter { Environment_ServerName = "Env1", Gender = "M", State = "CA", StoreID = storeId }; Configurator.Initialize( new Settings { Persister = new PersistToMongo("mongodb://localhost:27017/Graphene1", _fakeLogger), ReportGenerator = new MongoReportGenerator("mongodb://localhost:27017/Graphene1", _fakeLogger) } ); Container <TrackerWithCountProperties> .Where(filter1).Increment(t => t.ElderlyCount, 10); Thread.Sleep(new TimeSpan(0, 0, 5, 0)); Container <TrackerWithCountProperties> .Where(filter1).Increment(t => t.KidsCount, 5); Container <TrackerWithCountProperties> .Where(filter1).Increment(t => t.ElderlyCount, 2); Configurator.ShutDown(); AggregationResults <TrackerWithCountProperties> report = Container <TrackerWithCountProperties> .Where(new CustomerFilter { StoreID = storeId }).Report(DateTime.UtcNow.Subtract(new TimeSpan(1, 0, 0)), DateTime.UtcNow.Add(new TimeSpan(1, 0, 0))); System.Diagnostics.Debug.Write(report.Results.Count()); Assert.IsTrue(report.Results.Count() >= 1); Assert.AreEqual(12, report.Results[0].Tracker.ElderlyCount); Assert.AreEqual(5, report.Results[0].Tracker.KidsCount); }
/// <summary>Gets an aggregation result by name.</summary> /// <param name="name">The name.</param> /// <returns>The aggregation result or null.</returns> public AggregationResult GetByName(string name) { return(AggregationResults.SingleOrDefault(i => i.Name == name)); }
/// <summary>Gets an aggregation result by name.</summary> /// <param name="name">The name.</param> /// <returns>The aggregation result or null.</returns> public AggregationResult GetByName(string name) { // TODO: Rename to TryGetByName because it may return null? return(AggregationResults.SingleOrDefault(i => i.Name == name)); }