Skip to content

Commit

Permalink
tests: Move ManagedTracer test to its correct location
Browse files Browse the repository at this point in the history
  • Loading branch information
amanda-tarafa committed May 24, 2021
1 parent bb0c7b2 commit 0c006c6
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -75,20 +75,6 @@ public void CreateTraceHeaderContext_UseBackUpFunc()
Assert.Equal(TraceHeaderContext.FromHeader(header).ToString(), headerContext.ToString());
}

[Fact]
public void CreateManagedTracer()
{
var mockProvider = new Mock<IServiceProvider>();
var mockTracer = new Mock<IManagedTracer>();
string traceId = Guid.NewGuid().ToString("N");
mockTracer.Setup(p => p.GetCurrentTraceId()).Returns(traceId);
ContextTracerManager.SetCurrentTracer(mockTracer.Object);
var tracer = ManagedTracer.CreateDelegatingTracer(() => ContextTracerManager.GetCurrentTracer());
Assert.IsType<DelegatingTracer>(tracer);
Assert.Equal(traceId, tracer.GetCurrentTraceId());
mockTracer.Verify();
}

[Fact]
public void GetServiceCheckNotNull()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
// Copyright 2021 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// https://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.

using Moq;
using System;
using Xunit;

namespace Google.Cloud.Diagnostics.Common.Tests
{
public class ManagedTracerTest
{
[Fact]
public void CreateDelegatingTracer()
{
var mockTracer = new Mock<IManagedTracer>();
string traceId = Guid.NewGuid().ToString("N");
mockTracer.Setup(p => p.GetCurrentTraceId()).Returns(traceId);

var tracer = ManagedTracer.CreateDelegatingTracer(() => mockTracer.Object);

Assert.IsType<DelegatingTracer>(tracer);
Assert.Equal(traceId, tracer.GetCurrentTraceId());
mockTracer.Verify();
}
}
}

0 comments on commit 0c006c6

Please sign in to comment.