示例#1
0
        public void Tracer_Dispose_ShouldDisposeCorrectly()
        {
            _builtTracer.Dispose();

            _mockSampler.Received(1).Dispose();
            _mockReporter.Received(1).Dispose();
        }
        public void IsSampled_ShouldCallSampler()
        {
            var op      = "op";
            var traceId = new TraceId(452);

            _mockSampler.IsSampled(Arg.Is <TraceId>(tid => tid == traceId), Arg.Is <string>(on => on == op))
            .Returns((true, new Dictionary <string, object>()));

            var isSampled = _testingSampler.IsSampled(traceId, op);

            Assert.True(isSampled.Sampled);
            _mockSampler.Received(1).IsSampled(Arg.Any <TraceId>(), Arg.Any <string>());
        }
示例#3
0
        public void TestDispose()
        {
            IReporter reporter = Substitute.For <IReporter>();
            ISampler  sampler  = Substitute.For <ISampler>();

            var tracer = new Tracer.Builder("bonda")
                         .WithReporter(reporter)
                         .WithSampler(sampler)
                         .Build();

            tracer.Dispose();
            reporter.Received(1).CloseAsync(Arg.Any <CancellationToken>());
            sampler.Received(1).Close();
        }
示例#4
0
 public void TestSample()
 {
     _undertest.Sample("op", new TraceId(1L));
     _initialSampler.Received(1).Sample("op", new TraceId(1L));
 }