public async Task PayloadSentWithProperUserAgent() { var isRequestFinished = new TaskCompletionSource <object>(); HttpHeaderValueCollection <ProductInfoHeaderValue> userAgentHeader = null; var handler = new MockHttpMessageHandler((r, c) => { userAgentHeader = r.Headers.UserAgent; isRequestFinished.SetResult(null); return(Task.FromResult(new HttpResponseMessage(HttpStatusCode.OK))); }); var logger = new NoopLogger(); var service = Service.GetDefaultService(new TestAgentConfigurationReader(logger), logger); var payloadSender = new PayloadSenderV2(logger, new TestAgentConfigurationReader(logger), service, new Api.System(), handler); using (var agent = new ApmAgent(new TestAgentComponents(payloadSender: payloadSender))) { agent.PayloadSender.QueueTransaction(new Transaction(agent, "TestName", "TestType")); } await isRequestFinished.Task; userAgentHeader .Should() .NotBeEmpty() .And.HaveCount(3); userAgentHeader.First().Product.Name.Should().Be($"elasticapm-{Consts.AgentName}"); userAgentHeader.First().Product.Version.Should().NotBeEmpty(); userAgentHeader.Skip(1).First().Product.Name.Should().Be("System.Net.Http"); userAgentHeader.Skip(1).First().Product.Version.Should().NotBeEmpty(); userAgentHeader.Skip(2).First().Product.Name.Should().NotBeEmpty(); userAgentHeader.Skip(2).First().Product.Version.Should().NotBeEmpty(); }