public void RetainTransactionTraces_IfServerErrorException() { var transactionCollector = new SlowestTransactionCollector(); var transactionCollectors = new[] { transactionCollector }; var scheduler = Mock.Create <IScheduler>(); Mock.Arrange(() => scheduler.ExecuteEvery(Arg.IsAny <Action>(), Arg.IsAny <TimeSpan>(), Arg.IsAny <TimeSpan?>())) .DoInstead <Action, TimeSpan, TimeSpan?>((action, _, __) => _harvestAction = action); _transactionTraceAggregator = new TransactionTraceAggregator(_dataTransportService, scheduler, _processStatic, transactionCollectors); EventBus <AgentConnectedEvent> .Publish(new AgentConnectedEvent()); var sentTraces = Enumerable.Empty <TransactionTraceWireModel>(); Mock.Arrange(() => _dataTransportService.Send(Arg.IsAny <IEnumerable <TransactionTraceWireModel> >())) .Returns <IEnumerable <TransactionTraceWireModel> >(traces => { sentTraces = traces; return(DataTransportResponseStatus.Retain); }); var trace = new TransactionTraceWireModelComponents(new TransactionMetricName(), TimeSpan.FromSeconds(5), false, () => Mock.Create <TransactionTraceWireModel>()); _transactionTraceAggregator.Collect(trace); _harvestAction(); sentTraces = Enumerable.Empty <TransactionTraceWireModel>(); //reset _harvestAction(); Assert.AreEqual(1, sentTraces.Count()); }
public void When_transaction_traces_disabled_harvest_is_not_scheduled() { _configurationAutoResponder.Dispose(); _transactionTraceAggregator.Dispose(); var configuration = Mock.Create <IConfiguration>(); Mock.Arrange(() => configuration.TransactionTracerEnabled).Returns(false); _configurationAutoResponder = new ConfigurationAutoResponder(configuration); _transactionTraceAggregator = new TransactionTraceAggregator(_dataTransportService, _scheduler, _processStatic, _transactionCollectors); EventBus <AgentConnectedEvent> .Publish(new AgentConnectedEvent()); Mock.Assert(() => _scheduler.StopExecuting(null, null), Args.Ignore()); }
public void SetUp() { var configuration = Mock.Create <IConfiguration>(); Mock.Arrange(() => configuration.CollectorSendDataOnExit).Returns(true); Mock.Arrange(() => configuration.CollectorSendDataOnExitThreshold).Returns(0); Mock.Arrange(() => configuration.TransactionTracerEnabled).Returns(true); _configurationAutoResponder = new ConfigurationAutoResponder(configuration); _dataTransportService = Mock.Create <IDataTransportService>(); _dnsStatic = Mock.Create <IDnsStatic>(); _processStatic = Mock.Create <IProcessStatic>(); _transactionCollector1 = Mock.Create <ITransactionCollector>(); _transactionCollector2 = Mock.Create <ITransactionCollector>(); _transactionCollectors = new[] { _transactionCollector1, _transactionCollector2 }; _scheduler = Mock.Create <IScheduler>(); Mock.Arrange(() => _scheduler.ExecuteEvery(Arg.IsAny <Action>(), Arg.IsAny <TimeSpan>(), Arg.IsAny <TimeSpan?>())) .DoInstead <Action, TimeSpan, TimeSpan?>((action, harvestCycle, __) => { _harvestAction = action; _harvestCycle = harvestCycle; }); _transactionTraceAggregator = new TransactionTraceAggregator(_dataTransportService, _scheduler, _processStatic, _transactionCollectors); EventBus <AgentConnectedEvent> .Publish(new AgentConnectedEvent()); }