public void TryTake_EmptyCollection_NotReturnSpan() { var collection = new BlockingCollection <Span>(); var collector = new SpanCollector(collection); Span span; var ret = collector.TryTake(out span); Assert.IsFalse(ret); Assert.IsNull(span); }
public void TryTake_NotEmptyCollection_ReturnSpan() { var traceInfo = new TraceInfo(string.Empty, "TestSpanId", true, false, null, IPAddress.Loopback); var span = new Span(string.Empty, traceInfo); var collection = new BlockingCollection <Span>(); var collector = new SpanCollector(collection); collection.Add(span); Span spanTaken; var ret = collector.TryTake(out spanTaken); Assert.IsTrue(ret); Assert.AreSame(spanTaken, span); }
public void TryTake_NotEmptyCollection_ClearCollection() { var traceInfo = new TraceInfo(string.Empty, "TestSpanId", true, false, null, IPAddress.Loopback); var span = new Span(string.Empty, traceInfo); var collection = new BlockingCollection <Span>(); var collector = new SpanCollector(collection); collection.Add(span); Assert.AreEqual(collection.Count, 1); Span spanTaken; collector.TryTake(out spanTaken); Assert.AreEqual(collection.Count, 0); }