Initialize() public method

Populates device properties on a telemetry item.
public Initialize ( ITelemetry telemetry ) : void
telemetry ITelemetry
return void
Beispiel #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);
        }