-
Notifications
You must be signed in to change notification settings - Fork 140
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Skip the duck typing tests that won't work and add some others
- Loading branch information
1 parent
e4deba4
commit b3e4322
Showing
4 changed files
with
88 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
77 changes: 77 additions & 0 deletions
77
tracer/test/Datadog.Trace.Tests/ManualInstrumentation/ManualOnlyTests.cs
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,77 @@ | ||
// <copyright file="ManualOnlyTests.cs" company="Datadog"> | ||
// Unless explicitly stated otherwise all files in this repository are licensed under the Apache 2 License. | ||
// This product includes software developed at Datadog (https://www.datadoghq.com/). Copyright 2017 Datadog, Inc. | ||
// </copyright> | ||
|
||
extern alias DatadogTraceManual; | ||
|
||
using System; | ||
using FluentAssertions; | ||
using Xunit; | ||
using BenchmarkDiscreteStats = DatadogTraceManual::Datadog.Trace.Ci.BenchmarkDiscreteStats; | ||
using BenchmarkHostInfo = DatadogTraceManual::Datadog.Trace.Ci.BenchmarkHostInfo; | ||
using BenchmarkJobInfo = DatadogTraceManual::Datadog.Trace.Ci.BenchmarkJobInfo; | ||
using BenchmarkMeasureType = DatadogTraceManual::Datadog.Trace.Ci.BenchmarkMeasureType; | ||
using ManualScope = DatadogTraceManual::Datadog.Trace.ManualScope; | ||
using ManualSpan = DatadogTraceManual::Datadog.Trace.ManualSpan; | ||
using ManualSpanContext = DatadogTraceManual::Datadog.Trace.ManualSpanContext; | ||
using ManualTest = DatadogTraceManual::Datadog.Trace.Ci.ManualTest; | ||
using ManualTestModule = DatadogTraceManual::Datadog.Trace.Ci.ManualTestModule; | ||
using ManualTestSession = DatadogTraceManual::Datadog.Trace.Ci.ManualTestSession; | ||
using ManualTestSuite = DatadogTraceManual::Datadog.Trace.Ci.ManualTestSuite; | ||
using TestParameters = DatadogTraceManual::Datadog.Trace.Ci.TestParameters; | ||
using TestStatus = DatadogTraceManual::Datadog.Trace.Ci.TestStatus; | ||
|
||
namespace Datadog.Trace.Tests.ManualInstrumentation; | ||
|
||
public class ManualOnlyTests | ||
{ | ||
[Fact] | ||
public void CreatingAManualSpanDoesNotCrash() | ||
{ | ||
using var scope = DatadogTraceManual::Datadog.Trace.Tracer.Instance.StartActive("manual"); | ||
scope.Should().BeOfType<ManualScope>().And.NotBeNull(); | ||
|
||
var span = scope.Span.Should().NotBeNull().And.BeOfType<ManualSpan>().Subject; | ||
span.SetException(new Exception()); | ||
span.SetTag("James", "Bond"); | ||
span.GetTag("James").Should().BeNull(); | ||
span.OperationName.Should().BeNullOrEmpty(); | ||
span.ResourceName.Should().BeNullOrEmpty(); | ||
|
||
var context = span.Context.Should().NotBeNull().And.BeOfType<ManualSpanContext>().Subject; | ||
context.Should().NotBeNull(); | ||
context.ServiceName.Should().BeNullOrEmpty(); | ||
} | ||
|
||
[Fact] | ||
public void CreatingAManualOnlyCiSessionDoesNotCrash() | ||
{ | ||
var manualSession = DatadogTraceManual::Datadog.Trace.Ci.TestSession.GetOrCreate("some sesssion"); | ||
manualSession.Should().BeOfType<ManualTestSession>().And.NotBeNull(); | ||
manualSession.SetTag("session_key", "session_value"); | ||
|
||
var module = manualSession.CreateModule("somemodule"); | ||
module.Should().BeOfType<ManualTestModule>().And.NotBeNull(); | ||
module.SetTag("module_key", "module_value"); | ||
module.SetErrorInfo(new Exception()); | ||
|
||
var suite = module.GetOrCreateSuite("mysuite"); | ||
suite.Should().BeOfType<ManualTestSuite>().And.NotBeNull(); | ||
suite.SetTag("suite_key", "suite_value"); | ||
|
||
var test = suite.CreateTest("mytest"); | ||
test.Should().BeOfType<ManualTest>().And.NotBeNull(); | ||
test.SetTag("key", "value"); | ||
|
||
test.SetParameters(new TestParameters { Arguments = new(), Metadata = new() }); | ||
test.SetBenchmarkMetadata(new BenchmarkHostInfo() { RuntimeVersion = "123" }, new BenchmarkJobInfo() { Description = "weeble" }); | ||
var stats = new BenchmarkDiscreteStats(100, 100, 100, 100, 100, 0, 0, 0, 0, 100, 100, 100); | ||
test.AddBenchmarkData(BenchmarkMeasureType.ApplicationLaunch, info: "something", in stats); | ||
|
||
test.Close(TestStatus.Pass); | ||
suite.Close(); | ||
module.Close(); | ||
manualSession.Close(TestStatus.Pass); | ||
} | ||
} |
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