A telemetry context initializer that will gather device context information.
Inheritance: ITelemetryInitializer
Esempio n. 1
0
        public void ReadingDeviceUniqueIdYieldsCorrectValue()
        {
            DeviceTelemetryInitializer source = new DeviceTelemetryInitializer();
            var requestTelemetry = new RequestTelemetry();

            Assert.Null(requestTelemetry.Context.Device.Id);

            source.Initialize(requestTelemetry);

            string id = requestTelemetry.Context.Device.Id;

            string domainName = IPGlobalProperties.GetIPGlobalProperties().DomainName;
            string hostName   = Dns.GetHostName();

            if (hostName.EndsWith(domainName, StringComparison.OrdinalIgnoreCase) == false)
            {
                hostName = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", hostName, domainName);
            }

            Assert.Equal(hostName, id);
        }
        public void ReadingDeviceUniqueIdYieldsCorrectValue()
        {
            DeviceTelemetryInitializer source = new DeviceTelemetryInitializer();
            var requestTelemetry = new RequestTelemetry();

            Assert.Null(requestTelemetry.Context.Device.Id);

            source.Initialize(requestTelemetry);

            string id = requestTelemetry.Context.Device.Id;

            string domainName = IPGlobalProperties.GetIPGlobalProperties().DomainName;
            string hostName = Dns.GetHostName();

            if (hostName.EndsWith(domainName, StringComparison.OrdinalIgnoreCase) == false)
            {
                hostName = string.Format(CultureInfo.InvariantCulture, "{0}.{1}", hostName, domainName);
            }

            Assert.Equal(hostName, id);
        }