public void ShouldThrowInvalidOperationExceptionIfNoTraceIsActive( [Frozen] IAWSXRayRecorder recorder, [Target] AwsXRayTracingService service ) { Action func = service.EndTrace; func.Should().Throw <InvalidOperationException>(); }
public void ShouldEndTraceSegments( [Frozen] IAWSXRayRecorder recorder, [Target] AwsXRayTracingService service ) { service.StartTrace(); service.EndTrace(); recorder.Received().EndSegment(); }
public void ShouldReturnNullIfNoTraceIsActive( string id, string parent, string header, [Frozen, Substitute] ITracingIdService tracingIdService, [Target] AwsXRayTracingService service ) { service.Header.Should().BeNull(); }
public void ShouldThrowIfNoTraceIsActive( string name, string value, [Frozen] IAWSXRayRecorder recorder, [Target] AwsXRayTracingService service ) { Action func = () => service.AddMetadata(name, value); func.Should().Throw <InvalidOperationException>(); }
public void ShouldReturnTheCurrentTraceHeader( string id, [Frozen, Substitute] ITracingIdService tracingIdService, [Target] AwsXRayTracingService service ) { tracingIdService.CreateId().Returns(id); tracingIdService.GetIdFromHeader(Any <string?>()).Returns(null as string); service.StartTrace(); service.Header.Should().Be($"Root={id}; Sampled=1"); }
public void ShouldAddMetadata( string name, string value, [Frozen] IAWSXRayRecorder recorder, [Target] AwsXRayTracingService service ) { service.StartTrace(); service.AddMetadata(name, value); recorder.Received().AddMetadata(Is(name), Is(value)); }
public void ShouldStopTraceWhenContextIsDisposed( string header, string parentId, string traceId, [Frozen, Substitute] ITracingIdService tracingIdService, [Frozen, Substitute] IAWSXRayRecorder recorder, [Target] AwsXRayTracingService service ) { tracingIdService.CreateId().Returns(traceId); tracingIdService.GetIdFromHeader(Is(header)).Returns(parentId); using (var context = service.StartTrace(header)) { } recorder.Received().EndSegment(); }
public void ShouldStartSegmentWithNewId( string traceId, [Frozen, Substitute] ITracingIdService tracingIdService, [Frozen, Substitute] IAWSXRayRecorder recorder, [Target] AwsXRayTracingService service ) { tracingIdService.CreateId().Returns(traceId); tracingIdService.GetIdFromHeader(Any <string>()).Returns(null as string); service.StartTrace(); recorder.Received().BeginSegment( name: Is(AwsXRayTracingService.ServiceName), traceId: Is(traceId), parentId: Is(null as string), samplingResponse: Is <SamplingResponse>(response => response.SampleDecision == SampleDecision.Sampled) ); }