Skip to content

Commit f6a9a08

Browse files
Re-organize unit tests somewhat
1 parent df9ba01 commit f6a9a08

File tree

2 files changed

+32
-16
lines changed

2 files changed

+32
-16
lines changed

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

-16
Original file line numberDiff line numberDiff line change
@@ -27,22 +27,6 @@ public SpanLinksTests()
2727
_tracer = new Tracer(settings, writerMock.Object, samplerMock.Object, scopeManager: null, statsd: null);
2828
}
2929

30-
[Fact]
31-
public void AddLink_AfterSpanFinished_IsNoOp()
32-
{
33-
var parentScope = (Scope)_tracer.StartActive("Parent");
34-
var childScope = (Scope)_tracer.StartActive("Child");
35-
36-
var parentSpan = parentScope.Span;
37-
var childSpan = childScope.Span;
38-
var spanLink = new SpanLink(parentSpan.Context);
39-
40-
childSpan.Finish();
41-
42-
childSpan.AddLink(spanLink);
43-
childSpan.SpanLinks.Should().BeNullOrEmpty();
44-
}
45-
4630
[Fact]
4731
public void AddAttribute_BeforeSpanFinished_IsSuccessful()
4832
{

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

+32
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,38 @@ public void SetPeerServiceTag_CallsRemapper()
6969
span.GetTag(Tags.PeerServiceRemappedFrom).Should().Be("a-peer-service");
7070
}
7171

72+
[Fact]
73+
public void AddLink_BeforeSpanFinished_IsSuccessful()
74+
{
75+
var parentScope = (Scope)_tracer.StartActive("Parent");
76+
var childScope = (Scope)_tracer.StartActive("Child");
77+
78+
var parentSpan = parentScope.Span;
79+
var childSpan = childScope.Span;
80+
var spanLink = new SpanLink(parentSpan.Context);
81+
82+
childSpan.AddLink(spanLink);
83+
childSpan.Finish();
84+
85+
childSpan.SpanLinks.Should().ContainSingle();
86+
}
87+
88+
[Fact]
89+
public void AddLink_AfterSpanFinished_IsNoOp()
90+
{
91+
var parentScope = (Scope)_tracer.StartActive("Parent");
92+
var childScope = (Scope)_tracer.StartActive("Child");
93+
94+
var parentSpan = parentScope.Span;
95+
var childSpan = childScope.Span;
96+
var spanLink = new SpanLink(parentSpan.Context);
97+
98+
childSpan.Finish();
99+
childSpan.AddLink(spanLink);
100+
101+
childSpan.SpanLinks.Should().BeNullOrEmpty();
102+
}
103+
72104
[Fact]
73105
public void Finish_StartTimeInThePastWithNoEndTime_DurationProperlyComputed()
74106
{

0 commit comments

Comments
 (0)