public void CreateSpan() { Mock <TraceService.TraceServiceClient> mockGrpcClient = new Mock <TraceService.TraceServiceClient>(MockBehavior.Strict); apis::Span request = new apis::Span { SpanName = new SpanName("[PROJECT]", "[TRACE]", "[SPAN]"), SpanId = "spanId-2011840976", DisplayName = new TruncatableString(), StartTime = new Timestamp(), EndTime = new Timestamp(), }; apis::Span expectedResponse = new apis::Span { SpanName = new SpanName("[PROJECT]", "[TRACE]", "[SPAN]"), SpanId = "spanId2-643891741", ParentSpanId = "parentSpanId-1757797477", }; mockGrpcClient.Setup(x => x.CreateSpan(request, It.IsAny <CallOptions>())) .Returns(expectedResponse); TraceServiceClient client = new TraceServiceClientImpl(mockGrpcClient.Object, null); apis::Span response = client.CreateSpan(request); Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }
public void CreateSpanRequestObject() { moq::Mock <TraceService.TraceServiceClient> mockGrpcClient = new moq::Mock <TraceService.TraceServiceClient>(moq::MockBehavior.Strict); Span request = new Span { SpanName = SpanName.FromProjectTraceSpan("[PROJECT]", "[TRACE]", "[SPAN]"), SpanId = "span_id47c232d3", ParentSpanId = "parent_span_ide637f6a2", DisplayName = new TruncatableString(), StartTime = new wkt::Timestamp(), EndTime = new wkt::Timestamp(), Attributes = new Span.Types.Attributes(), StackTrace = new StackTrace(), TimeEvents = new Span.Types.TimeEvents(), Links = new Span.Types.Links(), Status = new gr::Status(), SameProcessAsParentSpan = false, ChildSpanCount = -1491694397, SpanKind = Span.Types.SpanKind.Consumer, }; Span expectedResponse = new Span { SpanName = SpanName.FromProjectTraceSpan("[PROJECT]", "[TRACE]", "[SPAN]"), SpanId = "span_id47c232d3", ParentSpanId = "parent_span_ide637f6a2", DisplayName = new TruncatableString(), StartTime = new wkt::Timestamp(), EndTime = new wkt::Timestamp(), Attributes = new Span.Types.Attributes(), StackTrace = new StackTrace(), TimeEvents = new Span.Types.TimeEvents(), Links = new Span.Types.Links(), Status = new gr::Status(), SameProcessAsParentSpan = false, ChildSpanCount = -1491694397, SpanKind = Span.Types.SpanKind.Consumer, }; mockGrpcClient.Setup(x => x.CreateSpan(request, moq::It.IsAny <grpccore::CallOptions>())).Returns(expectedResponse); TraceServiceClient client = new TraceServiceClientImpl(mockGrpcClient.Object, null); Span response = client.CreateSpan(request); xunit::Assert.Same(expectedResponse, response); mockGrpcClient.VerifyAll(); }