Initialize() 개인적인 메소드

private Initialize ( TelemetryContext source, string instrumentationKey ) : void
source TelemetryContext
instrumentationKey string
리턴 void
예제 #1
0
        public void InitializeSetsTelemetryInstrumentationKeyFromArgument()
        {
            var source = new TelemetryContext {
                InstrumentationKey = "TestValue"
            };
            var target = new TelemetryContext();

            target.Initialize(source, "OtherTestValue");

            Assert.Equal("OtherTestValue", target.InstrumentationKey);
        }
예제 #2
0
        public void InitializeDoesNotOverrideTelemetryInstrumentationKey()
        {
            var source = new TelemetryContext {
                InstrumentationKey = "SourceValue"
            };
            var target = new TelemetryContext {
                InstrumentationKey = "TargetValue"
            };

            target.Initialize(source, source.InstrumentationKey);

            Assert.Equal("TargetValue", target.InstrumentationKey);
        }
예제 #3
0
        public void InitializeCopiesTags()
        {
            string tagName  = "TestTag";
            string tagValue = "TestValue";
            var    source   = new TelemetryContext {
                Tags = { { tagName, tagValue } }
            };
            var target = new TelemetryContext();

            target.Initialize(source, source.InstrumentationKey);

            Assert.Equal(tagValue, target.Tags[tagName]);
        }
예제 #4
0
        private static string CopyAndSerialize(TelemetryContext source)
        {
            // Create a copy of the source context to verify that Serialize writes property values stored in tags
            // dictionary even if their context objects (User, Location, etc) haven't been initialized yet.
            var target = new TelemetryContext();

            target.Initialize(source, source.InstrumentationKey);

            using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture))
            {
                ((IJsonSerializable)target).Serialize(new JsonWriter(stringWriter));
                return(stringWriter.ToString());
            }
        }
예제 #5
0
        public void InitializeDoesNotOverwriteTags()
        {
            string tagName = "TestTag";
            var    source  = new TelemetryContext {
                Tags = { { tagName, "Source Value" } }
            };
            var target = new TelemetryContext {
                Tags = { { tagName, "Target Value" } }
            };

            target.Initialize(source, source.InstrumentationKey);

            Assert.Equal("Target Value", target.Tags[tagName]);
        }
        public void InitializeCopiesTags()
        {
            string tagName = "TestTag";
            string tagValue = "TestValue";
            var source = new TelemetryContext { Tags = { { tagName, tagValue } } };
            var target = new TelemetryContext();

            target.Initialize(source, source.InstrumentationKey);

            Assert.Equal(tagValue, target.Tags[tagName]);
        }
        private static string CopyAndSerialize(TelemetryContext source)
        {
            // Create a copy of the source context to verify that Serialize writes property values stored in tags 
            // dictionary even if their context objects (User, Location, etc) haven't been initialized yet.
            var target = new TelemetryContext();
            target.Initialize(source, source.InstrumentationKey);

            using (var stringWriter = new StringWriter(CultureInfo.InvariantCulture))
            {
                ((IJsonSerializable)target).Serialize(new JsonWriter(stringWriter));
                return stringWriter.ToString();
            }
        }
        public void InitializeDoesNotOverrideTelemetryInstrumentationKey()
        {
            var source = new TelemetryContext { InstrumentationKey = "SourceValue" };
            var target = new TelemetryContext { InstrumentationKey = "TargetValue" };

            target.Initialize(source, source.InstrumentationKey);

            Assert.Equal("TargetValue", target.InstrumentationKey);
        }
        public void InitializeSetsTelemetryInstrumentationKeyFromArgument()
        {
            var source = new TelemetryContext { InstrumentationKey = "TestValue" };
            var target = new TelemetryContext();

            target.Initialize(source, "OtherTestValue");

            Assert.Equal("OtherTestValue", target.InstrumentationKey);
        }
        public void InitializeDoesNotOverwriteTags()
        {
            string tagName = "TestTag";
            var source = new TelemetryContext { Tags = { { tagName, "Source Value" } } };
            var target = new TelemetryContext { Tags = { { tagName, "Target Value" } } };

            target.Initialize(source, source.InstrumentationKey);

            Assert.Equal("Target Value", target.Tags[tagName]);
        }