Skip to content

Commit

Permalink
Re-organize unit tests somewhat
Browse files Browse the repository at this point in the history
  • Loading branch information
zacharycmontoya committed Dec 4, 2024
1 parent 3d70a71 commit 0717792
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 16 deletions.
16 changes: 0 additions & 16 deletions tracer/test/Datadog.Trace.Tests/SpanLinksTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,22 +27,6 @@ public SpanLinksTests()
_tracer = new Tracer(settings, writerMock.Object, samplerMock.Object, scopeManager: null, statsd: null);
}

[Fact]
public void AddLink_AfterSpanFinished_IsNoOp()
{
var parentScope = (Scope)_tracer.StartActive("Parent");
var childScope = (Scope)_tracer.StartActive("Child");

var parentSpan = parentScope.Span;
var childSpan = childScope.Span;
var spanLink = new SpanLink(parentSpan.Context);

childSpan.Finish();

childSpan.AddLink(spanLink);
childSpan.SpanLinks.Should().BeNullOrEmpty();
}

[Fact]
public void AddAttribute_BeforeSpanFinished_IsSuccessful()
{
Expand Down
32 changes: 32 additions & 0 deletions tracer/test/Datadog.Trace.Tests/SpanTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,38 @@ public void SetPeerServiceTag_CallsRemapper()
span.GetTag(Tags.PeerServiceRemappedFrom).Should().Be("a-peer-service");
}

[Fact]
public void AddLink_BeforeSpanFinished_IsSuccessful()
{
var parentScope = (Scope)_tracer.StartActive("Parent");
var childScope = (Scope)_tracer.StartActive("Child");

var parentSpan = parentScope.Span;
var childSpan = childScope.Span;
var spanLink = new SpanLink(parentSpan.Context);

childSpan.AddLink(spanLink);
childSpan.Finish();

childSpan.SpanLinks.Should().ContainSingle();
}

[Fact]
public void AddLink_AfterSpanFinished_IsNoOp()
{
var parentScope = (Scope)_tracer.StartActive("Parent");
var childScope = (Scope)_tracer.StartActive("Child");

var parentSpan = parentScope.Span;
var childSpan = childScope.Span;
var spanLink = new SpanLink(parentSpan.Context);

childSpan.Finish();
childSpan.AddLink(spanLink);

childSpan.SpanLinks.Should().BeNullOrEmpty();
}

[Fact]
public void Finish_StartTimeInThePastWithNoEndTime_DurationProperlyComputed()
{
Expand Down

0 comments on commit 0717792

Please sign in to comment.