Skip to content

Commit

Permalink
Renamed test classes
Browse files Browse the repository at this point in the history
  • Loading branch information
ngruson committed Dec 4, 2023
1 parent eb58a0b commit b1c9676
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
// </copyright>

using System.Diagnostics;
using OpenTelemetry.Shims.OpenTracing.Tests.Mock;
using OpenTelemetry.Trace;
using Xunit;

Expand Down Expand Up @@ -56,7 +55,7 @@ public void Activate_SpanMustBeShim()
{
var shim = new ScopeManagerShim();

Assert.Throws<InvalidCastException>(() => shim.Activate(new MockSpan(), true));
Assert.Throws<InvalidCastException>(() => shim.Activate(new TestSpan(), true));
}

[Fact]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="MockFormatTextMap.cs" company="OpenTelemetry Authors">
// <copyright file="TestFormatTextMap.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,8 +16,8 @@

using OpenTracing.Propagation;

namespace OpenTelemetry.Shims.OpenTracing.Tests.Mock;
namespace OpenTelemetry.Shims.OpenTracing.Tests;

internal class MockFormatTextMap : IFormat<ITextMap>
internal class TestFormatTextMap : IFormat<ITextMap>
{
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="MockSpan.cs" company="OpenTelemetry Authors">
// <copyright file="TestSpan.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,9 +17,9 @@
using OpenTracing;
using OpenTracing.Tag;

namespace OpenTelemetry.Shims.OpenTracing.Tests.Mock;
namespace OpenTelemetry.Shims.OpenTracing.Tests;

internal class MockSpan : ISpan
internal class TestSpan : ISpan
{
public ISpanContext Context => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="MockSpanContext.cs" company="OpenTelemetry Authors">
// <copyright file="TestSpanContext.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -16,9 +16,9 @@

using OpenTracing;

namespace OpenTelemetry.Shims.OpenTracing.Tests.Mock;
namespace OpenTelemetry.Shims.OpenTracing.Tests;

internal class MockSpanContext : ISpanContext
internal class TestSpanContext : ISpanContext
{
public string TraceId => throw new NotImplementedException();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
// <copyright file="MockTextMap.cs" company="OpenTelemetry Authors">
// <copyright file="TestTextMap.cs" company="OpenTelemetry Authors">
// Copyright The OpenTelemetry Authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand All @@ -17,16 +17,17 @@
using System.Collections;
using OpenTracing.Propagation;

namespace OpenTelemetry.Shims.OpenTracing.Tests.Mock;
namespace OpenTelemetry.Shims.OpenTracing.Tests;

internal class MockTextMap : ITextMap
internal class TestTextMap : ITextMap
{
public bool GetEnumeratorCalled { get; private set; }

public bool SetCalled { get; private set; }

#pragma warning disable SA1010 // Opening square brackets should be spaced correctly
public Dictionary<string, string> Items { get; } = [];
#pragma warning restore SA1010 // Opening square brackets should be spaced correctly
#pragma warning disable IDE0028 // Simplify collection initialization
public Dictionary<string, string> Items { get; } = new();
#pragma warning restore IDE0028 // Simplify collection initialization

public IEnumerator<KeyValuePair<string, string>> GetEnumerator()
{
Expand Down
22 changes: 11 additions & 11 deletions test/OpenTelemetry.Shims.OpenTracing.Tests/TracerShimTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
using System.Collections;
using System.Diagnostics;
using OpenTelemetry.Context.Propagation;
using OpenTelemetry.Shims.OpenTracing.Tests.Mock;
using OpenTelemetry.Trace;
using OpenTracing;
using OpenTracing.Propagation;
Expand Down Expand Up @@ -61,11 +60,11 @@ public void Inject_ArgumentValidation()
var shim = new TracerShim(TracerProvider.Default, new TraceContextPropagator());

var spanContextShim = new SpanContextShim(new SpanContext(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.None));
var mockFormat = new MockFormatTextMap();
var mockCarrier = new MockTextMap();
var mockFormat = new TestFormatTextMap();
var mockCarrier = new TestTextMap();

Assert.Throws<ArgumentNullException>(() => shim.Inject(null, mockFormat, mockCarrier));
Assert.Throws<InvalidCastException>(() => shim.Inject(new MockSpanContext(), mockFormat, mockCarrier));
Assert.Throws<InvalidCastException>(() => shim.Inject(new TestSpanContext(), mockFormat, mockCarrier));
Assert.Throws<ArgumentNullException>(() => shim.Inject(spanContextShim, null, mockCarrier));
Assert.Throws<ArgumentNullException>(() => shim.Inject(spanContextShim, mockFormat, null));
}
Expand All @@ -78,8 +77,8 @@ public void Inject_UnknownFormatIgnored()
var spanContextShim = new SpanContextShim(new SpanContext(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.Recorded));

// Only two specific types of ITextMap are supported, and neither is a Mock.
var mockCarrier = new MockTextMap();
shim.Inject(spanContextShim, new MockFormatTextMap(), mockCarrier);
var mockCarrier = new TestTextMap();
shim.Inject(spanContextShim, new TestFormatTextMap(), mockCarrier);

// Verify that the carrier mock was never called.
Assert.False(mockCarrier.SetCalled);
Expand All @@ -90,8 +89,8 @@ public void Extract_ArgumentValidation()
{
var shim = new TracerShim(TracerProvider.Default, new TraceContextPropagator());

Assert.Throws<ArgumentNullException>(() => shim.Extract(null, new MockTextMap()));
Assert.Throws<ArgumentNullException>(() => shim.Extract(new MockFormatTextMap(), null));
Assert.Throws<ArgumentNullException>(() => shim.Extract(null, new TestTextMap()));
Assert.Throws<ArgumentNullException>(() => shim.Extract(new TestFormatTextMap(), null));
}

[Fact]
Expand All @@ -102,8 +101,8 @@ public void Extract_UnknownFormatIgnored()
var spanContextShim = new SpanContextShim(new SpanContext(ActivityTraceId.CreateRandom(), ActivitySpanId.CreateRandom(), ActivityTraceFlags.None));

// Only two specific types of ITextMap are supported, and neither is a Mock.
var mockCarrier = new MockTextMap();
var context = shim.Extract(new MockFormatTextMap(), mockCarrier);
var mockCarrier = new TestTextMap();
var context = shim.Extract(new TestFormatTextMap(), mockCarrier);

// Verify that the carrier mock was never called.
Assert.False(mockCarrier.SetCalled);
Expand All @@ -114,7 +113,8 @@ public void Extract_InvalidTraceParent()
{
var shim = new TracerShim(TracerProvider.Default, new TraceContextPropagator());

var mockCarrier = new MockTextMap();
var mockCarrier = new TestTextMap();

// The ProxyTracer uses OpenTelemetry.Context.Propagation.TraceContextPropagator, so we need to satisfy the traceparent key at the least
mockCarrier.Items["traceparent"] = "unused";

Expand Down

0 comments on commit b1c9676

Please sign in to comment.