-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixes error where empty Transaction has throws exception when no Stpa…
…ns. (#21)
- Loading branch information
1 parent
eccb3f8
commit 32d8c38
Showing
3 changed files
with
125 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,122 @@ | ||
using ContribSentry.Extensibility; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Text; | ||
using Xunit; | ||
|
||
namespace ContribSentry.TracingTest | ||
{ | ||
public class SentryTracingTests | ||
{ | ||
[Fact] | ||
public void Ctor_ValidSentryTracing() | ||
{ | ||
//Act | ||
var sentryTracing = new SentryTracing(null, 0); | ||
|
||
//Assert | ||
Assert.True(sentryTracing != null); | ||
} | ||
|
||
[Fact] | ||
public void StartChild_AddsChild() | ||
{ | ||
//Arrange | ||
var sentryTracing = new SentryTracing(null, 0); | ||
|
||
//Act | ||
var span = sentryTracing.StartChild("name","name"); | ||
|
||
//Assert | ||
Assert.Contains(span, sentryTracing.Spans); | ||
|
||
} | ||
|
||
[Fact] | ||
public void GetSpan_EmptySpan_DisabledSpan() | ||
{ | ||
//Arrange | ||
var sentryTracing = new SentryTracing(null, 0); | ||
|
||
//Act | ||
var span = sentryTracing.GetSpan("name"); | ||
|
||
//Assert | ||
Assert.IsType<DisabledSpan>(span); | ||
} | ||
|
||
[Fact] | ||
public void GetSpan_OpExist_SpanWithOp() | ||
{ | ||
//Arrange | ||
var sentryTracing = new SentryTracing(null, 0); | ||
sentryTracing.StartChild("name", "name"); | ||
|
||
//Act | ||
var span = sentryTracing.GetSpan("name"); | ||
|
||
//Assert | ||
Assert.IsType<Span>(span); | ||
Assert.Equal("name", span.Op); | ||
} | ||
|
||
[Fact] | ||
public void GetCurrentSpan_NoSpan_DisabledSpan() | ||
{ | ||
//Arrange | ||
var sentryTracing = new SentryTracing(null, 0); | ||
|
||
//Act | ||
var span = sentryTracing.GetCurrentSpan(); | ||
|
||
//Assert | ||
Assert.IsType<DisabledSpan>(span); | ||
} | ||
|
||
[Fact] | ||
public void GetCurrentSpan_FirstSpanOpen_FirstSpan() | ||
{ | ||
//Arrange | ||
var sentryTracing = new SentryTracing(null, 0); | ||
sentryTracing.StartChild("name", "name"); | ||
|
||
//Act | ||
var span = sentryTracing.GetCurrentSpan(); | ||
|
||
//Assert | ||
Assert.IsType<Span>(span); | ||
Assert.Equal("name", span.Op); | ||
} | ||
|
||
[Fact] | ||
public void GetCurrentSpan_FirstSpanOpenAndSecondIsChildofChild_FirstSpan() | ||
{ | ||
//Arrange | ||
var sentryTracing = new SentryTracing(null, 0); | ||
var parent = sentryTracing.StartChild("name", "name"); | ||
parent.StartChild("aaa"); | ||
|
||
//Act | ||
var span = sentryTracing.GetCurrentSpan(); | ||
|
||
//Assert | ||
Assert.IsType<Span>(span); | ||
Assert.Equal("name", span.Op); | ||
} | ||
|
||
[Fact] | ||
public void Finish_NoSpan_CapturesEvent() | ||
{ | ||
//Arrange | ||
ContribSentrySdk.Init(new ContribSentryOptions()); | ||
ContribSentrySdk.Options.TracesSampleRate = 1.0; | ||
|
||
var sentryTracing = new SentryTracing(null, 0); | ||
|
||
//Act | ||
sentryTracing.Finish(); | ||
|
||
ContribSentrySdk.Close(); | ||
} | ||
} | ||
} |