public void ContextInitializerDoesNotOverrideMachineName()
        {
            var source = new DomainNameRoleInstanceContextInitializer();
            var telemetryContext = new TelemetryContext();
            telemetryContext.Device.RoleInstance = "Test";

            source.Initialize(telemetryContext);

            Assert.Equal("Test", telemetryContext.Device.RoleInstance);
        }
        public void RoleInstanceNameIsSetToDomainAndHost()
        {
            var source = new DomainNameRoleInstanceContextInitializer();
            var telemetryContext = new TelemetryContext();

            source.Initialize(telemetryContext);
            
            string hostName = Dns.GetHostName();

#if !dnxcore50
            string domainName = IPGlobalProperties.GetIPGlobalProperties().DomainName;
            if (hostName.EndsWith(domainName, StringComparison.OrdinalIgnoreCase) == false)
            {
                hostName = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", hostName, domainName);
            }
#endif

            Assert.Equal(hostName, telemetryContext.Device.RoleInstance);
        }