/// <summary>
        /// Reports a maximum set of values for the recompiles to support the Summary Metric on the New Relic dashboard
        /// </summary>
        /// <param name="results"></param>
        /// <returns></returns>
        internal IQueryContext GetMaxRecompileSummaryMetric(IEnumerable <object> results)
        {
            if (results == null)
            {
                return(null);
            }

            var recompileSummaries = results.OfType <RecompileSummary>().ToArray();

            if (!recompileSummaries.Any())
            {
                return(null);
            }

            var max = new RecompileMaximums
            {
                SingleUsePercent   = recompileSummaries.Max(s => s.SingleUsePercent),
                SingleUseObjects   = recompileSummaries.Max(s => s.SingleUseObjects),
                MultipleUseObjects = recompileSummaries.Max(s => s.MultipleUseObjects),
            };

            var metricQuery = new MetricQuery(typeof(RecompileMaximums), typeof(RecompileMaximums).Name, typeof(RecompileMaximums).Name);

            return(CreateQueryContext(metricQuery, new[] { max }));
        }
        public void Assert_only_numerics_are_returned()
        {
            MetricMapper[] metricMappers = MetricQuery.GetMappers(typeof(FakeQueryType));
            Assert.That(metricMappers, Is.Not.Null);

            // Keep these out of order to ensure we don't depend on it
            var expected = new[] { "Long", "Integer", "Short", "Decimal", "Byte" };

            string[] actual = metricMappers.Select(m => m.MetricName).ToArray();
            Assert.That(actual, Is.EquivalentTo(expected), "Properties discovered and mapped wrong");
        }
        /// <summary>
        ///     Reports a maximum set of values for the recompiles to support the Summary Metric on the New Relic dashboard
        /// </summary>
        /// <param name="results"></param>
        /// <returns></returns>
        internal IQueryContext GetMaxRecompileSummaryMetric(IEnumerable<object> results)
        {
            if (results == null) return null;

            RecompileSummary[] recompileSummaries = results.OfType<RecompileSummary>().ToArray();
            if (!recompileSummaries.Any()) return null;

            var max = new RecompileMaximums
                      {
                          SingleUsePercent = recompileSummaries.Max(s => s.SingleUsePercent),
                          SingleUseObjects = recompileSummaries.Max(s => s.SingleUseObjects),
                          MultipleUseObjects = recompileSummaries.Max(s => s.MultipleUseObjects),
                      };

            var metricQuery = new MetricQuery(typeof (RecompileMaximums), typeof (RecompileMaximums).Name, typeof (RecompileMaximums).Name);
            return CreateQueryContext(metricQuery, new[] {max});
        }