示例#1
0
        private static Mock <Trace.ISpanBuilder> GetDefaultSpanBuilderMock(SpanMock spanMock = null)
        {
            var mock = new Mock <Trace.ISpanBuilder>();

            spanMock = spanMock ?? Defaults.GetOpenTelemetrySpanMock();
            mock.Setup(x => x.StartSpan()).Returns(spanMock);

            return(mock);
        }
        private static Mock <Tracer> GetDefaultTracerMock(SpanMock spanMock = null)
        {
            var mock = new Mock <Tracer>();

            spanMock = spanMock ?? Defaults.GetOpenTelemetrySpanMock();

            mock.Setup(x => x.StartRootSpan(It.IsAny <string>(), It.IsAny <SpanKind>(), It.IsAny <SpanCreationOptions>())).Returns(spanMock);
            mock.Setup(x => x.StartSpan(It.IsAny <string>(), It.IsAny <TelemetrySpan>(), It.IsAny <SpanKind>(), It.IsAny <SpanCreationOptions>())).Returns(spanMock);
            mock.Setup(x => x.StartSpan(It.IsAny <string>(), It.IsAny <SpanContext>(), It.IsAny <SpanKind>(), It.IsAny <SpanCreationOptions>())).Returns(spanMock);
            mock.Setup(x => x.StartSpanFromActivity(It.IsAny <string>(), It.IsAny <Activity>(), It.IsAny <SpanKind>(), It.IsAny <IEnumerable <Link> >())).Returns(spanMock);
            return(mock);
        }