Skip to content

Commit df7ca37

Browse files
committed
More test fixes
1 parent c374851 commit df7ca37

File tree

3 files changed

+9
-6
lines changed

3 files changed

+9
-6
lines changed

tracer/test/Datadog.Trace.Tests/Agent/MessagePack/TraceChunkModelTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
using System.Collections.Generic;
88
using System.Linq;
99
using Datadog.Trace.Agent.MessagePack;
10+
using Datadog.Trace.Tests.Util;
1011
using FluentAssertions;
1112
using Moq;
1213
using Xunit;
@@ -492,7 +493,7 @@ private static TraceChunkModel CreateTraceChunk(IEnumerable<Span> spans, Span ro
492493
private Span CreateSpan(ulong traceId, ulong spanId, ulong parentId)
493494
{
494495
var parentContent = new SpanContext(traceId, parentId);
495-
var traceContext = new TraceContext(Mock.Of<IDatadogTracer>());
496+
var traceContext = new TraceContext(new StubDatadogTracer());
496497
var spanContext = new SpanContext(parentContent, traceContext, serviceName: null, spanId: spanId);
497498
return new Span(spanContext, DateTimeOffset.UtcNow);
498499
}

tracer/test/Datadog.Trace.Tests/Agent/StatsAggregatorTests.cs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
using Datadog.Trace.Agent.DiscoveryService;
1414
using Datadog.Trace.Configuration;
1515
using Datadog.Trace.ExtensionMethods;
16+
using Datadog.Trace.Tests.Util;
1617
using FluentAssertions;
1718
using Moq;
1819
using Xunit;
@@ -201,15 +202,15 @@ public async Task CollectsMeasuredSpans_TS004()
201202
parentSpan.SetDuration(TimeSpan.FromMilliseconds(100));
202203

203204
// childSpan shouldn't be recorded, because it's not top-level and doesn't have the Measured tag
204-
var childSpan = new Span(new SpanContext(parentSpan.Context, new TraceContext(Mock.Of<IDatadogTracer>()), "service"), start);
205+
var childSpan = new Span(new SpanContext(parentSpan.Context, new TraceContext(new StubDatadogTracer()), "service"), start);
205206
childSpan.SetDuration(TimeSpan.FromMilliseconds(100));
206207

207-
var measuredChildSpan1 = new Span(new SpanContext(parentSpan.Context, new TraceContext(Mock.Of<IDatadogTracer>()), "service"), start);
208+
var measuredChildSpan1 = new Span(new SpanContext(parentSpan.Context, new TraceContext(new StubDatadogTracer()), "service"), start);
208209
measuredChildSpan1.OperationName = "child.op1";
209210
measuredChildSpan1.SetTag(Tags.Measured, "1");
210211
measuredChildSpan1.SetDuration(TimeSpan.FromMilliseconds(100));
211212

212-
var measuredChildSpan2 = new Span(new SpanContext(parentSpan.Context, new TraceContext(Mock.Of<IDatadogTracer>()), "service"), start);
213+
var measuredChildSpan2 = new Span(new SpanContext(parentSpan.Context, new TraceContext(new StubDatadogTracer()), "service"), start);
213214
measuredChildSpan2.OperationName = "child.op2";
214215
measuredChildSpan2.SetTag(Tags.Measured, "1");
215216
measuredChildSpan2.SetDuration(TimeSpan.FromMilliseconds(100));
@@ -271,7 +272,7 @@ public async Task CollectsTopLevelSpans_TS005()
271272
snapshotSpan.SetDuration(TimeSpan.FromMilliseconds(300));
272273

273274
// Create a new child span that is a service entry span, which means it will have stats computed for it
274-
var httpClientServiceSpan = new Span(new SpanContext(parentSpan.Context, new TraceContext(Mock.Of<IDatadogTracer>()), "service-http-client"), start);
275+
var httpClientServiceSpan = new Span(new SpanContext(parentSpan.Context, new TraceContext(new StubDatadogTracer()), "service-http-client"), start);
275276
httpClientServiceSpan.SetDuration(TimeSpan.FromMilliseconds(400));
276277

277278
aggregator.Add(simpleSpan, parentSpan, snapshotSpan, httpClientServiceSpan);

tracer/test/Datadog.Trace.Tests/SpanContextTests.cs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
using System.Collections.Generic;
77
using System.Linq;
88
using Datadog.Trace.Tagging;
9+
using Datadog.Trace.Tests.Util;
910
using FluentAssertions;
1011
using Moq;
1112
using Xunit;
@@ -147,7 +148,7 @@ private static IReadOnlyDictionary<string, string> CreateSpanContext()
147148
propagatedTags.SetTag("_dd.p.key1", "value1");
148149
propagatedTags.SetTag("_dd.p.key2", "value2");
149150

150-
var traceContext = new TraceContext(Mock.Of<IDatadogTracer>(), propagatedTags);
151+
var traceContext = new TraceContext(new StubDatadogTracer(), propagatedTags);
151152
traceContext.SetSamplingPriority(samplingPriority);
152153
traceContext.Origin = origin;
153154
traceContext.AdditionalW3CTraceState = additionalW3CTraceState;

0 commit comments

Comments
 (0)