public void ToBuilder_RemoveDuplicatesFromUnknownTagContext() { var tag1 = new DistributedContextEntry(K1, V1); var tag2 = new DistributedContextEntry(K1, V2); ITagContext tagContextWithDuplicateTags = new SimpleTagContext(tag1, tag2); var newTagContext = tagger.ToBuilder(tagContextWithDuplicateTags).Build(); Assert.Equal(new List <DistributedContextEntry>() { tag2 }, TagsTestUtil.TagContextToList(newTagContext)); }
public void WithTagContext() { Assert.Empty(TagsTestUtil.TagContextToList(tagger.CurrentTagContext)); var scopedTags = tagger.EmptyBuilder.Put(KEY_1, VALUE_1).Build(); var scope = tagger.WithTagContext(scopedTags); try { Assert.Same(scopedTags, tagger.CurrentTagContext); } finally { scope.Dispose(); } Assert.Empty(TagsTestUtil.TagContextToList(tagger.CurrentTagContext)); }
public void SetCurrentTagsWithBuilder() { Assert.Empty(TagsTestUtil.TagContextToList(tagger.CurrentTagContext)); var scope = tagger.EmptyBuilder.Put(KEY_1, VALUE_1).BuildScoped(); try { Assert.Equal(new List <DistributedContextEntry>() { new DistributedContextEntry(KEY_1, VALUE_1) }, TagsTestUtil.TagContextToList(tagger.CurrentTagContext)); } finally { scope.Dispose(); } Assert.Empty(TagsTestUtil.TagContextToList(tagger.CurrentTagContext)); }
public void CreateBuilderFromCurrentTags() { var scopedTags = tagger.EmptyBuilder.Put(KEY_1, VALUE_1).Build(); var scope = tagger.WithTagContext(scopedTags); try { var newTags = tagger.CurrentBuilder.Put(KEY_2, VALUE_2).Build(); Assert.Equal(new List <DistributedContextEntry>() { new DistributedContextEntry(KEY_1, VALUE_1), new DistributedContextEntry(KEY_2, VALUE_2) }, TagsTestUtil.TagContextToList(newTags)); Assert.Same(scopedTags, tagger.CurrentTagContext); } finally { scope.Dispose(); } }