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 Collect_SendsTraceToAllCollectors() { var trace = Mock.Create <TransactionTraceWireModelComponents>(); _transactionTraceAggregator.Collect(trace); foreach (var collector in _transactionCollectors) { Mock.Assert(() => collector.Collect(trace)); } }