public void SpanBuilder_BadArguments() { Assert.Throws <ArgumentNullException>(() => new SpanBuilder(null, spanBuilderOptions)); Assert.Throws <ArgumentNullException>(() => new SpanBuilder(SpanName, null)); var spanBuilder = new SpanBuilder(SpanName, spanBuilderOptions); Assert.Throws <ArgumentNullException>(() => spanBuilder.SetParent((ISpan)null)); Assert.Throws <ArgumentNullException>(() => spanBuilder.SetParent((SpanContext)null)); Assert.Throws <ArgumentNullException>(() => spanBuilder.SetParent((Activity)null)); // no Activity.Current Assert.Throws <ArgumentException>(() => spanBuilder.SetCreateChild(false)); // Activity.Current wrong format Activity.DefaultIdFormat = ActivityIdFormat.Hierarchical; Activity.ForceDefaultIdFormat = true; var a = new Activity("foo").Start(); // TODO SetIdFormat Assert.Throws <ArgumentException>(() => spanBuilder.SetCreateChild(false)); a.Stop(); Assert.Throws <ArgumentNullException>(() => spanBuilder.SetSampler(null)); Assert.Throws <ArgumentNullException>(() => spanBuilder.AddLink((Activity)null)); Assert.Throws <ArgumentNullException>(() => spanBuilder.AddLink((ILink)null)); Assert.Throws <ArgumentNullException>(() => spanBuilder.AddLink((SpanContext)null)); Assert.Throws <ArgumentNullException>(() => spanBuilder.AddLink(null, null)); Assert.Throws <ArgumentNullException>(() => spanBuilder.AddLink(SpanContext.Blank, null)); }
public void SpanBuilder_BadArguments() { var spanBuilder = new SpanBuilder(SpanName, spanBuilderOptions); Assert.Throws <ArgumentNullException>(() => spanBuilder.SetParent((ISpan)null)); Assert.Throws <ArgumentNullException>(() => spanBuilder.SetParent((SpanContext)null)); Assert.Throws <ArgumentNullException>(() => spanBuilder.SetSampler(null)); Assert.Throws <ArgumentNullException>(() => spanBuilder.AddLink((ILink)null)); Assert.Throws <ArgumentNullException>(() => spanBuilder.AddLink((SpanContext)null)); Assert.Throws <ArgumentNullException>(() => spanBuilder.AddLink(null, null)); Assert.Throws <ArgumentNullException>(() => spanBuilder.AddLink(SpanContext.Blank, null)); }