diff --git a/apis/Google.Cloud.Diagnostics.AspNetCore/Google.Cloud.Diagnostics.AspNetCore.Tests/Trace/CloudTraceExtensionTest.cs b/apis/Google.Cloud.Diagnostics.AspNetCore/Google.Cloud.Diagnostics.AspNetCore.Tests/Trace/CloudTraceExtensionTest.cs index 4ef2596e950a..8de9d5d10e09 100644 --- a/apis/Google.Cloud.Diagnostics.AspNetCore/Google.Cloud.Diagnostics.AspNetCore.Tests/Trace/CloudTraceExtensionTest.cs +++ b/apis/Google.Cloud.Diagnostics.AspNetCore/Google.Cloud.Diagnostics.AspNetCore.Tests/Trace/CloudTraceExtensionTest.cs @@ -75,20 +75,6 @@ public void CreateTraceHeaderContext_UseBackUpFunc() Assert.Equal(TraceHeaderContext.FromHeader(header).ToString(), headerContext.ToString()); } - [Fact] - public void CreateManagedTracer() - { - var mockProvider = new Mock(); - var mockTracer = new Mock(); - 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(tracer); - Assert.Equal(traceId, tracer.GetCurrentTraceId()); - mockTracer.Verify(); - } - [Fact] public void GetServiceCheckNotNull() { diff --git a/apis/Google.Cloud.Diagnostics.Common/Google.Cloud.Diagnostics.Common.Tests/Trace/ManagedTracerTest.cs b/apis/Google.Cloud.Diagnostics.Common/Google.Cloud.Diagnostics.Common.Tests/Trace/ManagedTracerTest.cs new file mode 100644 index 000000000000..0ddbc6e68826 --- /dev/null +++ b/apis/Google.Cloud.Diagnostics.Common/Google.Cloud.Diagnostics.Common.Tests/Trace/ManagedTracerTest.cs @@ -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(); + string traceId = Guid.NewGuid().ToString("N"); + mockTracer.Setup(p => p.GetCurrentTraceId()).Returns(traceId); + + var tracer = ManagedTracer.CreateDelegatingTracer(() => mockTracer.Object); + + Assert.IsType(tracer); + Assert.Equal(traceId, tracer.GetCurrentTraceId()); + mockTracer.Verify(); + } + } +} \ No newline at end of file