예제 #1
0
        public void GivenAFilterListWithEmptyFilters_WhenBuildingAReportSpecification_EmptyObjectValuesAreIgnored()
        {
            List <object> filtersWithTwoEmptyObjects = new List <object> {
                new FilteringStringFake(null, string.Empty), new FilteringStringFake("A", "B"), new FilteringStringFake(null, null)
            };

            var specification = new ReportSpecification(new[] { typeof(CustomerAgeTracker) }, filtersWithTwoEmptyObjects,
                                                        DateTime.UtcNow, DateTime.UtcNow.AddDays(-100), ReportResolution.Day);

            Assert.AreEqual(1, specification.FilterCombinations.Count());
        }
예제 #2
0
        public void FirstTest()
        {
            var specification = new ReportSpecification(new[] { typeof(CustomerAgeTracker) },
                                                        DateTime.UtcNow.AddDays(-100), DateTime.UtcNow, ReportResolution.Hour);

            Assert.IsTrue(specification.Counters.Any());


            string serializedObject = JsonConvert.SerializeObject(specification, Formatting.Indented);

            Console.WriteLine(serializedObject);
        }
예제 #3
0
        public static AggregationResults <T1> Report(DateTime fromUtc, DateTime toUtc,
                                                     ReportSpecification <T, T1> reportSpecs)

        {
            ITrackerReportResults trackerReportResults =
                Configurator.Configuration.ReportGenerator.BuildReport(reportSpecs);

            var aggResults = new AggregationResults <T1> {
                Resolution = reportSpecs.Resolution
            };

            if (trackerReportResults == null)
            {
                return(aggResults);
            }

            foreach (IAggregationResult aggregationResult in trackerReportResults.AggregationResults)
            {
                var aggResult = new AggregationResult <T1>();
                aggResult.MesurementTimeUtc = aggregationResult.MesurementTimeUtc;


                aggResult.Occurrence = aggregationResult.Occurence;
                aggResult.Total      = aggregationResult.Total;


                foreach (IMeasurementResult mV in aggregationResult.MeasurementValues)
                {
                    Type type = aggResult.Tracker.GetType();

                    PropertyInfo property = null;
                    if (mV.PropertyName != null)
                    {
                        property = type.GetProperty(mV.PropertyName);
                    }
                    if (property != null)
                    {
                        object convertedValue = Convert.ChangeType(mV.Value, property.PropertyType);
                        property.SetValue(aggResult.Tracker, convertedValue);
                    }
                }
                aggResults.Results.Add(aggResult);
            }

            return(aggResults);
        }