public void Setup()
        {
            _compositeTestAgent = new CompositeTestAgent();
            _compositeTestAgent.SetEventListenerSamplersEnabled(true);

            _mockScheduler = Mock.Create <IScheduler>();

            //Prevents the scheduler from actually running
            Mock.Arrange(() => _mockScheduler.ExecuteEvery(Arg.IsAny <Action>(), Arg.IsAny <TimeSpan>(), Arg.IsAny <TimeSpan?>()))
            .DoNothing();


            _mockEventListener        = Mock.Create <ISampledEventListener <Dictionary <GCSampleType, float> > >();
            _mockEventListenerFactory = () => _mockEventListener;
            _mockTransformer          = Mock.Create <IGcSampleTransformer>();
        }
        public void Setup()
        {
            var metricNameService = new MetricNameService();

            _metricBuilder    = new MetricBuilder(metricNameService);
            _metricAggregator = Mock.Create <IMetricAggregator>();

            _transformer = new GcSampleTransformer(_metricBuilder, _metricAggregator);

            //Build example sample data
            var sampleValue = 0f;

            _sampleData = new Dictionary <GCSampleType, float>();
            foreach (var val in Enum.GetValues(typeof(GCSampleType)))
            {
                _sampleData.Add((GCSampleType)val, sampleValue++);
            }
            _sampleTypes      = _sampleData.Keys.ToArray();
            _sampleTypesCount = _sampleTypes.Length;
        }
        public GcSampler(IScheduler scheduler, IGcSampleTransformer gcSampleTransformer, IPerformanceCounterProxyFactory pcProxyFactory)
            : base(scheduler, TimeSpan.FromSeconds(GcSampleIntervalSeconds))
        {
            _pcProxyFactory = pcProxyFactory;
            _transformer    = gcSampleTransformer;

            //Assign functions to handle the values for the different performance counters collected.
            _perfCounterValueHandlers = new Dictionary <GCSampleType, Func <IPerformanceCounterProxy, float> >()
            {
                { GCSampleType.Gen0Size, GetPerfCounterValue_Raw },
                { GCSampleType.Gen0Promoted, GetPerfCounterValue_Raw },
                { GCSampleType.Gen1Size, GetPerfCounterValue_Raw },
                { GCSampleType.Gen1Promoted, GetPerfCounterValue_Raw },
                { GCSampleType.Gen2Size, GetPerfCounterValue_Raw },
                { GCSampleType.LOHSize, GetPerfCounterValue_Raw },
                { GCSampleType.HandlesCount, GetPerfCounterValue_Raw },
                { GCSampleType.InducedCount, GetPerfCounterValue_InducedCount },
                { GCSampleType.PercentTimeInGc, GetPerfCounterValue_Raw },
                { GCSampleType.Gen0CollectionCount, GetPerfCounterValue_Gen0CollectionCount },
                { GCSampleType.Gen1CollectionCount, GetPerfCounterValue_Gen1CollectionCount },
                { GCSampleType.Gen2CollectionCount, GetPerfCounterValue_Gen2CollectionCount }
            };
        }
 public GCSamplerNetCore(IScheduler scheduler, Func <ISampledEventListener <Dictionary <GCSampleType, float> > > eventListenerFactory, IGcSampleTransformer transformer, Func <SamplerIsApplicableToFrameworkResult> fxSamplerIsApplicableToFramework) : base(scheduler, TimeSpan.FromSeconds(GCSampleNetCoreIntervalSeconds))
 {
     _eventListenerFactory             = eventListenerFactory;
     _transformer                      = transformer;
     _fxSamplerIsApplicableToFramework = fxSamplerIsApplicableToFramework;
 }