예제 #1
0
        public void EmptyBuilder()
        {
            var builder = tagger.EmptyBuilder;

            Assert.IsType <TagContextBuilder>(builder);
            Assert.Empty(TagsTestUtil.TagContextToList(builder.Build()));
        }
예제 #2
0
        public void TestGetCurrentTagContext_DefaultContext()
        {
            var tags = CurrentTagContextUtils.CurrentTagContext;

            Assert.NotNull(tags);
            Assert.Empty(TagsTestUtil.TagContextToList(tags));
        }
예제 #3
0
        public void DefaultTagContext()
        {
            var defaultTagContext = tagger.CurrentTagContext;

            Assert.Empty(TagsTestUtil.TagContextToList(defaultTagContext));
            Assert.IsType <TagContext>(defaultTagContext);
        }
예제 #4
0
        public void CurrentBuilder_DefaultIsEmpty()
        {
            var currentBuilder = tagger.CurrentBuilder;

            Assert.IsType <TagContextBuilder>(currentBuilder);
            Assert.Empty(TagsTestUtil.TagContextToList(currentBuilder.Build()));
        }
예제 #5
0
        public void GetCurrentTagContext_DefaultIsEmptyTagContext()
        {
            var currentTagContext = tagger.CurrentTagContext;

            Assert.Empty(TagsTestUtil.TagContextToList(currentTagContext));
            Assert.IsType <TagContext>(currentTagContext);
        }
예제 #6
0
        public void AddToCurrentTagsWithBuilder()
        {
            var scopedTags = tagger.EmptyBuilder.Put(KEY_1, VALUE_1).Build();
            var scope1     = tagger.WithTagContext(scopedTags);

            try
            {
                var scope2 = tagger.CurrentBuilder.Put(KEY_2, VALUE_2).BuildScoped();
                try
                {
                    Assert.Equal(new List <DistributedContextEntry>()
                    {
                        new DistributedContextEntry(KEY_1, VALUE_1), new DistributedContextEntry(KEY_2, VALUE_2)
                    },
                                 TagsTestUtil.TagContextToList(tagger.CurrentTagContext));
                }
                finally
                {
                    scope2.Dispose();
                }
                Assert.Same(scopedTags, tagger.CurrentTagContext);
            }
            finally
            {
                scope1.Dispose();
            }
        }
예제 #7
0
        public void CurrentBuilder_SkipNullTag()
        {
            ITagContext tagContextWithNullTag = new SimpleTagContext(TAG1, null, TAG2);
            var         result = GetResultOfCurrentBuilder(tagContextWithNullTag);

            Assert.Equal(new List <DistributedContextEntry>()
            {
                TAG1, TAG2
            }, TagsTestUtil.TagContextToList(result.Build()));
        }
예제 #8
0
        public void ToBuilder_SkipNullTag()
        {
            ITagContext tagContextWithNullTag = new SimpleTagContext(TAG1, null, TAG2);
            var         newTagContext         = tagger.ToBuilder(tagContextWithNullTag).Build();

            Assert.Equal(new List <DistributedContextEntry>()
            {
                TAG1, TAG2
            }, TagsTestUtil.TagContextToList(newTagContext));
        }
예제 #9
0
        public void ToBuilder_ConvertUnknownTagContextToTagContext()
        {
            ITagContext unknownTagContext = new SimpleTagContext(TAG1, TAG2, TAG3);
            var         newTagContext     = tagger.ToBuilder(unknownTagContext).Build();

            Assert.Equal(new List <DistributedContextEntry>()
            {
                TAG1, TAG2, TAG3
            }, TagsTestUtil.TagContextToList(newTagContext));
            Assert.IsType <TagContext>(newTagContext);
        }
예제 #10
0
        public void WithTagContext_ConvertUnknownTagContextToTagContext()
        {
            ITagContext unknownTagContext = new SimpleTagContext(TAG1, TAG2, TAG3);
            var         result            = GetResultOfWithTagContext(unknownTagContext);

            Assert.IsType <TagContext>(result);
            Assert.Equal(new List <DistributedContextEntry>()
            {
                TAG1, TAG2, TAG3
            }, TagsTestUtil.TagContextToList(result));
        }
예제 #11
0
        public void CurrentBuilder()
        {
            ITagContext tags   = new SimpleTagContext(TAG1, TAG2, TAG3);
            var         result = GetResultOfCurrentBuilder(tags);

            Assert.IsType <TagContextBuilder>(result);
            Assert.Equal(new List <DistributedContextEntry>()
            {
                TAG1, TAG2, TAG3
            }, TagsTestUtil.TagContextToList(result.Build()));
        }
예제 #12
0
        public void CurrentBuilder_RemoveDuplicateTags()
        {
            var         tag1 = new DistributedContextEntry(K1, V1);
            var         tag2 = new DistributedContextEntry(K1, V2);
            ITagContext tagContextWithDuplicateTags = new SimpleTagContext(tag1, tag2);
            var         result = GetResultOfCurrentBuilder(tagContextWithDuplicateTags);

            Assert.Equal(new List <DistributedContextEntry>()
            {
                tag2
            }, TagsTestUtil.TagContextToList(result.Build()));
        }
예제 #13
0
        public void WithTagContext_RemoveDuplicatesFromUnknownTagContext()
        {
            var         tag1 = new DistributedContextEntry(K1, V1);
            var         tag2 = new DistributedContextEntry(K1, V2);
            ITagContext tagContextWithDuplicateTags = new SimpleTagContext(tag1, tag2);
            var         result = GetResultOfWithTagContext(tagContextWithDuplicateTags);

            Assert.Equal(new List <DistributedContextEntry>()
            {
                tag2
            }, TagsTestUtil.TagContextToList(result));
        }
예제 #14
0
        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));
        }
예제 #15
0
        public void TestGetCurrentTagContext_ContextSetToNull()
        {
            var orig = AsyncLocalContext.CurrentTagContext;

            AsyncLocalContext.CurrentTagContext = null;
            try
            {
                var tags = CurrentTagContextUtils.CurrentTagContext;
                Assert.NotNull(tags);
                Assert.Empty(TagsTestUtil.TagContextToList(tags));
            }
            finally
            {
                AsyncLocalContext.CurrentTagContext = orig;
            }
        }
예제 #16
0
        public void TestWithTagContext()
        {
            Assert.Empty(TagsTestUtil.TagContextToList(CurrentTagContextUtils.CurrentTagContext));

            var scopedTags = CurrentTagContextUtils.WithTagContext(tagContext);

            try
            {
                Assert.Same(tagContext, CurrentTagContextUtils.CurrentTagContext);
            }
            finally
            {
                scopedTags.Dispose();
            }
            Assert.Empty(TagsTestUtil.TagContextToList(CurrentTagContextUtils.CurrentTagContext));
        }
예제 #17
0
        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));
        }
예제 #18
0
        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));
        }
예제 #19
0
        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();
            }
        }
예제 #20
0
 public void Empty()
 {
     Assert.Empty(TagsTestUtil.TagContextToList(tagger.Empty));
     Assert.IsType <TagContext>(tagger.Empty);
 }