public void BroadcastProcessor_OneProcessorThrows() { bool start1Called = false; bool start2Called = false; bool end1Called = false; bool end2Called = false; var processor1 = new TestProcessor( ss => { start1Called = true; Assert.False(start2Called); Assert.False(end1Called); Assert.False(end2Called); throw new Exception("Start exception"); }, se => { end1Called = true; Assert.True(start1Called); Assert.True(start2Called); Assert.False(end2Called); throw new Exception("End exception"); }); var processor2 = new TestProcessor( ss => { start2Called = true; Assert.True(start1Called); Assert.False(end1Called); Assert.False(end2Called); }, se => { end2Called = true; Assert.True(start1Called); Assert.True(start2Called); Assert.True(end1Called); }); var broadcastProcessor = new BroadcastProcessor(new[] { processor1, processor2 }); var tracer = TracerFactory.Create(_ => { }).GetTracer(null); var span = (SpanSdk)tracer.StartSpan("foo"); var spanData = new SpanData(span); broadcastProcessor.OnStart(spanData); Assert.True(start1Called); Assert.True(start2Called); broadcastProcessor.OnEnd(spanData); Assert.True(end1Called); Assert.True(end2Called); }
public void BroadcastProcessor_CallsAllProcessorSequentially() { bool start1Called = false; bool start2Called = false; bool end1Called = false; bool end2Called = false; var processor1 = new TestProcessor(ss => { start1Called = true; Assert.False(start2Called); Assert.False(end1Called); Assert.False(end2Called); }, se => { end1Called = true; Assert.True(start1Called); Assert.True(start2Called); Assert.False(end2Called); }); var processor2 = new TestProcessor(ss => { start2Called = true; Assert.True(start1Called); Assert.False(end1Called); Assert.False(end2Called); }, se => { end2Called = true; Assert.True(start1Called); Assert.True(start2Called); Assert.True(end1Called); }); var broadcastProcessor = new BroadcastProcessor(new [] { processor1, processor2 }); var tracer = TracerFactory.Create(_ => { }).GetTracer(null); var span = (Span)tracer.StartSpan("foo"); broadcastProcessor.OnStart(span); Assert.True(start1Called); Assert.True(start2Called); broadcastProcessor.OnEnd(span); Assert.True(end1Called); Assert.True(end2Called); }