public void WithTagContext_RemoveDuplicatesFromUnknownTagContext() { var tag1 = Tag.Create(K1, V1); var tag2 = Tag.Create(K1, V2); ITagContext tagContextWithDuplicateTags = new SimpleTagContext(tag1, tag2); var result = GetResultOfWithTagContext(tagContextWithDuplicateTags); Assert.Equal(new List <Tag>() { tag2 }, TagsTestUtil.TagContextToList(result)); }
public void ToBuilder_RemoveDuplicatesFromUnknownTagContext() { var tag1 = Tag.Create(K1, V1); var tag2 = Tag.Create(K1, V2); ITagContext tagContextWithDuplicateTags = new SimpleTagContext(tag1, tag2); var newTagContext = tagger.ToBuilder(tagContextWithDuplicateTags).Build(); Assert.Equal(new List <Tag>() { tag2 }, TagsTestUtil.TagContextToList(newTagContext)); }
public void CurrentBuilder_RemoveDuplicateTags() { var tag1 = Tag.Create(K1, V1); var tag2 = Tag.Create(K1, V2); ITagContext tagContextWithDuplicateTags = new SimpleTagContext(tag1, tag2); var result = GetResultOfCurrentBuilder(tagContextWithDuplicateTags); Assert.Equal(new List <Tag>() { tag2 }, TagsTestUtil.TagContextToList(result.Build())); }
public void WithTagContext() { Assert.Empty(TagsTestUtil.TagContextToList(tagger.CurrentTagContext)); ITagContext scopedTags = tagger.EmptyBuilder.Put(KEY_1, VALUE_1).Build(); IScope scope = tagger.WithTagContext(scopedTags); try { Assert.Same(scopedTags, tagger.CurrentTagContext); } finally { scope.Dispose(); } Assert.Empty(TagsTestUtil.TagContextToList(tagger.CurrentTagContext)); }
public void TestWithTagContext() { Assert.Empty(TagsTestUtil.TagContextToList(CurrentTagContextUtils.CurrentTagContext)); IScope scopedTags = CurrentTagContextUtils.WithTagContext(tagContext); try { Assert.Same(tagContext, CurrentTagContextUtils.CurrentTagContext); } finally { scopedTags.Dispose(); } Assert.Empty(TagsTestUtil.TagContextToList(CurrentTagContextUtils.CurrentTagContext)); }
public void TestGetCurrentTagContext_ContextSetToNull() { var orig = AsyncLocalContext.CurrentTagContext; AsyncLocalContext.CurrentTagContext = null; try { ITagContext tags = CurrentTagContextUtils.CurrentTagContext; Assert.NotNull(tags); Assert.Empty(TagsTestUtil.TagContextToList(tags)); } finally { AsyncLocalContext.CurrentTagContext = orig; } }
public void SetCurrentTagsWithBuilder() { Assert.Empty(TagsTestUtil.TagContextToList(tagger.CurrentTagContext)); IScope scope = tagger.EmptyBuilder.Put(KEY_1, VALUE_1).BuildScoped(); try { Assert.Equal(new List <ITag>() { Tag.Create(KEY_1, VALUE_1) }, TagsTestUtil.TagContextToList(tagger.CurrentTagContext)); } finally { scope.Dispose(); } Assert.Empty(TagsTestUtil.TagContextToList(tagger.CurrentTagContext)); }
public void CreateBuilderFromCurrentTags() { ITagContext scopedTags = tagger.EmptyBuilder.Put(KEY_1, VALUE_1).Build(); IScope scope = tagger.WithTagContext(scopedTags); try { ITagContext newTags = tagger.CurrentBuilder.Put(KEY_2, VALUE_2).Build(); Assert.Equal(new List <ITag>() { Tag.Create(KEY_1, VALUE_1), Tag.Create(KEY_2, VALUE_2) }, TagsTestUtil.TagContextToList(newTags)); Assert.Same(scopedTags, tagger.CurrentTagContext); } finally { scope.Dispose(); } }
public void Empty() { Assert.Empty(TagsTestUtil.TagContextToList(tagger.Empty)); Assert.IsType <TagContext>(tagger.Empty); }