|
3 | 3 |
|
4 | 4 | using System; |
5 | 5 | using System.Collections.Generic; |
| 6 | +using NewRelic.Agent.Api.Experimental; |
| 7 | +using NewRelic.Agent.Configuration; |
| 8 | +using NewRelic.Agent.Core.Attributes; |
| 9 | +using NewRelic.Agent.Core.CallStack; |
| 10 | +using NewRelic.Agent.Core.DistributedTracing; |
| 11 | +using NewRelic.Agent.Core.DistributedTracing.Samplers; |
6 | 12 | using NewRelic.Agent.Core.Errors; |
7 | 13 | using NewRelic.Agent.Core.Metrics; |
8 | 14 | using NewRelic.Agent.Core.Segments.Tests; |
| 15 | +using NewRelic.Agent.Core.Time; |
9 | 16 | using NewRelic.Agent.Core.Transactions; |
| 17 | +using NewRelic.Agent.Core.Wrapper.AgentWrapperApi.Builders; |
10 | 18 | using NewRelic.Agent.Core.Wrapper.AgentWrapperApi.Data; |
11 | 19 | using NewRelic.Agent.Extensions.Api.Experimental; |
12 | 20 | using NUnit.Framework; |
@@ -532,4 +540,34 @@ public void SpanEventEvent_Constructor_SetsPropertiesCorrectly() |
532 | 540 | Assert.That(spanEvent.Attributes, Is.Not.Null); |
533 | 541 | }); |
534 | 542 | } |
| 543 | + |
| 544 | + [Test] |
| 545 | + public void GetTransactionGuid_ReturnsSuccessfully() |
| 546 | + { |
| 547 | + var priority = 0.0f; |
| 548 | + var configuration = Mock.Create<IConfiguration>(); |
| 549 | + Mock.Arrange(() => configuration.TransactionEventsEnabled).Returns(true); |
| 550 | + |
| 551 | + // Initialize the Transaction with its dependencies |
| 552 | + var attribDefSvc = new AttributeDefinitionService((f) => new AttributeDefinitions(f)); |
| 553 | + var databaseStatementParser = Mock.Create<IDatabaseStatementParser>(); |
| 554 | + var distributedTracePayloadHandler = Mock.Create<IDistributedTracePayloadHandler>(); |
| 555 | + |
| 556 | + var transaction = new Transaction(configuration, Mock.Create<ITransactionName>(), Mock.Create<ISimpleTimer>(), |
| 557 | + DateTime.UtcNow, Mock.Create<ICallStackManager>(), Mock.Create<IDatabaseService>(), |
| 558 | + priority, databaseStatementParser, distributedTracePayloadHandler, Mock.Create<IErrorService>(), attribDefSvc.AttributeDefs, Mock.Create<ISamplerService>()); |
| 559 | + var segment = new Segment(transaction.GetTransactionSegmentState(), new MethodCallData("Type", "Method", 1)); |
| 560 | + var transactionGuid = segment.GetTransactionGuid(); |
| 561 | + Assert.That(transactionGuid, Is.Not.Null); |
| 562 | + Assert.That(transactionGuid, Is.EqualTo(transaction.Guid)); |
| 563 | + } |
| 564 | + |
| 565 | + [Test] |
| 566 | + public void GetTransactionGuid_ReturnsEmptyWhenNoGuid() |
| 567 | + { |
| 568 | + var segment = new Segment(TransactionSegmentStateHelpers.GetItransactionSegmentState(), new MethodCallData("Type", "Method", 1)); |
| 569 | + var transactionGuid = segment.GetTransactionGuid(); |
| 570 | + Assert.That(transactionGuid, Is.Not.Null); |
| 571 | + Assert.That(transactionGuid, Is.EqualTo("empty")); |
| 572 | + } |
535 | 573 | } |
0 commit comments