public void Initialize_WhenGlobalDimensionsIsNotEmpty_SetsTelemetry()
        {
            var globalDimensions = new Dictionary <string, string>()
            {
                { "a", "b" },
                { "c", "d" }
            };
            var telemetryContext = new TelemetryContext();
            var telemetry        = new Mock <ITelemetry>();
            var telemetryService = new Mock <ITelemetryService>();

            telemetry.SetupGet(x => x.Context)
            .Returns(telemetryContext);

            telemetryService.SetupGet(x => x.GlobalDimensions)
            .Returns(globalDimensions);

            var initializer = new JobPropertiesTelemetryInitializer(telemetryService.Object);

            initializer.Initialize(telemetry.Object);

            Assert.Equal(2, telemetryContext.Properties.Count);
            Assert.Equal("b", telemetryContext.Properties["a"]);
            Assert.Equal("d", telemetryContext.Properties["c"]);
        }
        public void Initialize_WhenGlobalDimensionsIsEmpty_DoesNothing()
        {
            _telemetryService.SetupGet(x => x.GlobalDimensions)
            .Returns(_globalDimensions);

            var initializer = new JobPropertiesTelemetryInitializer(_telemetryService.Object);

            initializer.Initialize(_telemetry.Object);

            Assert.Empty(_telemetryContext.Properties);
        }
        public void Initialize_WhenGlobalDimensionsIsEmpty_SetsJobNameAndInstanceName()
        {
            var telemetry = new TestableTelemetry();

            var initializer = new JobPropertiesTelemetryInitializer(
                jobName: "a",
                instanceName: "b",
                globalDimensions: new Dictionary <string, string>());

            initializer.Initialize(telemetry);

            Assert.Equal(2, telemetry.Properties.Count);
            Assert.Equal("a", telemetry.Properties["JobName"]);
            Assert.Equal("b", telemetry.Properties["InstanceName"]);
        }
        public void Initialize_WhenGlobalDimensionsIsNotEmpty_SetsTelemetry()
        {
            var globalDimensions = new Dictionary <string, string>()
            {
                { "a", "b" },
                { "c", "d" }
            };
            var telemetry = new TestableTelemetry();

            var initializer = new JobPropertiesTelemetryInitializer(
                jobName: "jobName",
                instanceName: "instanceName",
                globalDimensions: globalDimensions);

            initializer.Initialize(telemetry);

            Assert.Equal(4, telemetry.Properties.Count);
            Assert.Equal("jobName", telemetry.Properties["JobName"]);
            Assert.Equal("instanceName", telemetry.Properties["InstanceName"]);
            Assert.Equal("b", telemetry.Properties["a"]);
            Assert.Equal("d", telemetry.Properties["c"]);
        }