public void Extract(string traceParent, string traceContext, string expectedTraceId, string expectedSpanId, string expectedParentSpanId, bool expectedIsSampled, bool expectedIsDebug, string expectedExtra)
        {
            var context = W3CPropagation.Extract(traceParent, traceContext);

            Assert.AreEqual(expectedTraceId, context.TraceIdHigh.ToString("x16") + context.TraceId.ToString("x16"));
            Assert.AreEqual(expectedSpanId, context.SpanId.ToString("x16"));
            Assert.AreEqual(expectedParentSpanId, context.ParentSpanId?.ToString("x16"));
            Assert.AreEqual(expectedIsSampled, context.Sampled ?? false);
            Assert.AreEqual(expectedIsDebug, context.Debug);
            Assert.AreEqual(expectedExtra, context.Extra?.First());
        }
        public void Inject(string traceId, string spanId, string parentSpanId, bool isSampled, bool isDebug, string context, string expectedTraceParent, string expectedTraceContext)
        {
            var traceIdHigh       = long.Parse(traceId.Substring(0, 16), NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture);
            var traceIdLow        = long.Parse(traceId.Substring(16, 16), NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture);
            var spanIdValue       = long.Parse(spanId, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture);
            var parentSpanIdValue = parentSpanId == null ? default(long?) : long.Parse(parentSpanId, NumberStyles.AllowHexSpecifier, CultureInfo.InvariantCulture);

            var w3cTraceContext = new W3CPropagation.W3CTraceContext(traceIdHigh, traceIdLow, spanIdValue, parentSpanIdValue, isSampled, isDebug, context);

            var(traceParent, traceContext) = W3CPropagation.CreateHeaderValues(w3cTraceContext);
            Assert.AreEqual(expectedTraceParent, traceParent);
            Assert.AreEqual(expectedTraceContext, traceContext);
        }
 public void IsValidTraceParent(string traceParent, bool expected)
 {
     Assert.AreEqual(expected, W3CPropagation.IsValidTraceParent(traceParent));
 }