< Summary

Class:Azure.Iot.Hub.Service.Models.DeviceIdentity
Assembly:Azure.Iot.Hub.Service
File(s):C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\DeviceIdentity.cs
C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\DeviceIdentity.Serialization.cs
Covered lines:131
Uncovered lines:10
Coverable lines:141
Total lines:280
Line coverage:92.9% (131 of 141)
Covered branches:57
Total branches:62
Branch coverage:91.9% (57 of 62)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-100%100%
get_DeviceId()-100%100%
get_GenerationId()-100%100%
get_Etag()-100%100%
get_ConnectionState()-100%100%
get_Status()-100%100%
get_StatusReason()-100%100%
get_ConnectionStateUpdatedTime()-100%100%
get_StatusUpdatedTime()-100%100%
get_LastActivityTime()-100%100%
get_CloudToDeviceMessageCount()-100%100%
get_Authentication()-100%100%
get_Capabilities()-100%100%
get_DeviceScope()-100%100%
get_ParentScopes()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-87.5%90%
DeserializeDeviceIdentity(...)-93.33%93.75%

File(s)

C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\DeviceIdentity.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Collections.Generic;
 10using Azure.Core;
 11
 12namespace Azure.Iot.Hub.Service.Models
 13{
 14    /// <summary> The Device. </summary>
 15    public partial class DeviceIdentity
 16    {
 17        /// <summary> Initializes a new instance of DeviceIdentity. </summary>
 21618        public DeviceIdentity()
 19        {
 21620            ParentScopes = new ChangeTrackingList<string>();
 21621        }
 22
 23        /// <summary> Initializes a new instance of DeviceIdentity. </summary>
 24        /// <param name="deviceId"> The unique identifier of the device. </param>
 25        /// <param name="generationId"> The IoT Hub-generated, case-sensitive string up to 128 characters long. This val
 26        /// <param name="etag"> The string representing a weak ETag for the device identity, as per RFC7232. </param>
 27        /// <param name="connectionState"> The state of the device. </param>
 28        /// <param name="status"> The status of the device. If the status disabled, a device cannot connect to the servi
 29        /// <param name="statusReason"> The 128 character-long string that stores the reason for the device identity sta
 30        /// <param name="connectionStateUpdatedTime"> The date and time the connection state was last updated. </param>
 31        /// <param name="statusUpdatedTime"> The date and time when the status field was last updated. </param>
 32        /// <param name="lastActivityTime"> The date and last time the device last connected, received, or sent a messag
 33        /// <param name="cloudToDeviceMessageCount"> The number of cloud-to-device messages currently queued to be sent 
 34        /// <param name="authentication"> The authentication mechanism used by the device. </param>
 35        /// <param name="capabilities"> The set of capabilities of the device. For example, if this device is an edge de
 36        /// <param name="deviceScope"> The scope of the device. Auto generated and immutable for edge devices and modifi
 37        /// <param name="parentScopes"> The scopes of the upper level edge devices if applicable. Only available for edg
 8038        internal DeviceIdentity(string deviceId, string generationId, string etag, DeviceConnectionState? connectionStat
 39        {
 8040            DeviceId = deviceId;
 8041            GenerationId = generationId;
 8042            Etag = etag;
 8043            ConnectionState = connectionState;
 8044            Status = status;
 8045            StatusReason = statusReason;
 8046            ConnectionStateUpdatedTime = connectionStateUpdatedTime;
 8047            StatusUpdatedTime = statusUpdatedTime;
 8048            LastActivityTime = lastActivityTime;
 8049            CloudToDeviceMessageCount = cloudToDeviceMessageCount;
 8050            Authentication = authentication;
 8051            Capabilities = capabilities;
 8052            DeviceScope = deviceScope;
 8053            ParentScopes = parentScopes;
 8054        }
 55
 56        /// <summary> The unique identifier of the device. </summary>
 173257        public string DeviceId { get; set; }
 58        /// <summary> The IoT Hub-generated, case-sensitive string up to 128 characters long. This value is used to dist
 16859        public string GenerationId { get; set; }
 60        /// <summary> The string representing a weak ETag for the device identity, as per RFC7232. </summary>
 48061        public string Etag { get; set; }
 62        /// <summary> The state of the device. </summary>
 16863        public DeviceConnectionState? ConnectionState { get; set; }
 64        /// <summary> The status of the device. If the status disabled, a device cannot connect to the service. </summar
 38465        public DeviceStatus? Status { get; set; }
 66        /// <summary> The 128 character-long string that stores the reason for the device identity status. All UTF-8 cha
 32067        public string StatusReason { get; set; }
 68        /// <summary> The date and time the connection state was last updated. </summary>
 16869        public DateTimeOffset? ConnectionStateUpdatedTime { get; set; }
 70        /// <summary> The date and time when the status field was last updated. </summary>
 16871        public DateTimeOffset? StatusUpdatedTime { get; set; }
 72        /// <summary> The date and last time the device last connected, received, or sent a message. </summary>
 16873        public DateTimeOffset? LastActivityTime { get; set; }
 74        /// <summary> The number of cloud-to-device messages currently queued to be sent to the device. </summary>
 16875        public int? CloudToDeviceMessageCount { get; set; }
 76        /// <summary> The authentication mechanism used by the device. </summary>
 33677        public AuthenticationMechanism Authentication { get; set; }
 78        /// <summary> The set of capabilities of the device. For example, if this device is an edge device or not. </sum
 33679        public DeviceCapabilities Capabilities { get; set; }
 80        /// <summary> The scope of the device. Auto generated and immutable for edge devices and modifiable in leaf devi
 32081        public string DeviceScope { get; set; }
 82        /// <summary> The scopes of the upper level edge devices if applicable. Only available for edge devices. </summa
 25283        public IList<string> ParentScopes { get; }
 84    }
 85}

C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\DeviceIdentity.Serialization.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4// <auto-generated/>
 5
 6#nullable disable
 7
 8using System;
 9using System.Collections.Generic;
 10using System.Text.Json;
 11using Azure.Core;
 12
 13namespace Azure.Iot.Hub.Service.Models
 14{
 15    public partial class DeviceIdentity : IUtf8JsonSerializable
 16    {
 17        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 18        {
 7219            writer.WriteStartObject();
 7220            if (Optional.IsDefined(DeviceId))
 21            {
 7222                writer.WritePropertyName("deviceId");
 7223                writer.WriteStringValue(DeviceId);
 24            }
 7225            if (Optional.IsDefined(GenerationId))
 26            {
 1627                writer.WritePropertyName("generationId");
 1628                writer.WriteStringValue(GenerationId);
 29            }
 7230            if (Optional.IsDefined(Etag))
 31            {
 1632                writer.WritePropertyName("etag");
 1633                writer.WriteStringValue(Etag);
 34            }
 7235            if (Optional.IsDefined(ConnectionState))
 36            {
 1637                writer.WritePropertyName("connectionState");
 1638                writer.WriteStringValue(ConnectionState.Value.ToString());
 39            }
 7240            if (Optional.IsDefined(Status))
 41            {
 2442                writer.WritePropertyName("status");
 2443                writer.WriteStringValue(Status.Value.ToString());
 44            }
 7245            if (Optional.IsDefined(StatusReason))
 46            {
 047                writer.WritePropertyName("statusReason");
 048                writer.WriteStringValue(StatusReason);
 49            }
 7250            if (Optional.IsDefined(ConnectionStateUpdatedTime))
 51            {
 1652                writer.WritePropertyName("connectionStateUpdatedTime");
 1653                writer.WriteStringValue(ConnectionStateUpdatedTime.Value, "O");
 54            }
 7255            if (Optional.IsDefined(StatusUpdatedTime))
 56            {
 1657                writer.WritePropertyName("statusUpdatedTime");
 1658                writer.WriteStringValue(StatusUpdatedTime.Value, "O");
 59            }
 7260            if (Optional.IsDefined(LastActivityTime))
 61            {
 1662                writer.WritePropertyName("lastActivityTime");
 1663                writer.WriteStringValue(LastActivityTime.Value, "O");
 64            }
 7265            if (Optional.IsDefined(CloudToDeviceMessageCount))
 66            {
 1667                writer.WritePropertyName("cloudToDeviceMessageCount");
 1668                writer.WriteNumberValue(CloudToDeviceMessageCount.Value);
 69            }
 7270            if (Optional.IsDefined(Authentication))
 71            {
 1672                writer.WritePropertyName("authentication");
 1673                writer.WriteObjectValue(Authentication);
 74            }
 7275            if (Optional.IsDefined(Capabilities))
 76            {
 1677                writer.WritePropertyName("capabilities");
 1678                writer.WriteObjectValue(Capabilities);
 79            }
 7280            if (Optional.IsDefined(DeviceScope))
 81            {
 082                writer.WritePropertyName("deviceScope");
 083                writer.WriteStringValue(DeviceScope);
 84            }
 7285            if (Optional.IsCollectionDefined(ParentScopes))
 86            {
 1287                writer.WritePropertyName("parentScopes");
 1288                writer.WriteStartArray();
 089                foreach (var item in ParentScopes)
 90                {
 091                    writer.WriteStringValue(item);
 92                }
 1293                writer.WriteEndArray();
 94            }
 7295            writer.WriteEndObject();
 7296        }
 97
 98        internal static DeviceIdentity DeserializeDeviceIdentity(JsonElement element)
 99        {
 80100            Optional<string> deviceId = default;
 80101            Optional<string> generationId = default;
 80102            Optional<string> etag = default;
 80103            Optional<DeviceConnectionState> connectionState = default;
 80104            Optional<DeviceStatus> status = default;
 80105            Optional<string> statusReason = default;
 80106            Optional<DateTimeOffset> connectionStateUpdatedTime = default;
 80107            Optional<DateTimeOffset> statusUpdatedTime = default;
 80108            Optional<DateTimeOffset> lastActivityTime = default;
 80109            Optional<int> cloudToDeviceMessageCount = default;
 80110            Optional<AuthenticationMechanism> authentication = default;
 80111            Optional<DeviceCapabilities> capabilities = default;
 80112            Optional<string> deviceScope = default;
 80113            Optional<IList<string>> parentScopes = default;
 2208114            foreach (var property in element.EnumerateObject())
 115            {
 1024116                if (property.NameEquals("deviceId"))
 117                {
 80118                    deviceId = property.Value.GetString();
 80119                    continue;
 120                }
 944121                if (property.NameEquals("generationId"))
 122                {
 80123                    generationId = property.Value.GetString();
 80124                    continue;
 125                }
 864126                if (property.NameEquals("etag"))
 127                {
 80128                    etag = property.Value.GetString();
 80129                    continue;
 130                }
 784131                if (property.NameEquals("connectionState"))
 132                {
 80133                    connectionState = new DeviceConnectionState(property.Value.GetString());
 80134                    continue;
 135                }
 704136                if (property.NameEquals("status"))
 137                {
 80138                    status = new DeviceStatus(property.Value.GetString());
 80139                    continue;
 140                }
 624141                if (property.NameEquals("statusReason"))
 142                {
 80143                    statusReason = property.Value.GetString();
 80144                    continue;
 145                }
 544146                if (property.NameEquals("connectionStateUpdatedTime"))
 147                {
 80148                    connectionStateUpdatedTime = property.Value.GetDateTimeOffset("O");
 80149                    continue;
 150                }
 464151                if (property.NameEquals("statusUpdatedTime"))
 152                {
 80153                    statusUpdatedTime = property.Value.GetDateTimeOffset("O");
 80154                    continue;
 155                }
 384156                if (property.NameEquals("lastActivityTime"))
 157                {
 80158                    lastActivityTime = property.Value.GetDateTimeOffset("O");
 80159                    continue;
 160                }
 304161                if (property.NameEquals("cloudToDeviceMessageCount"))
 162                {
 80163                    cloudToDeviceMessageCount = property.Value.GetInt32();
 80164                    continue;
 165                }
 224166                if (property.NameEquals("authentication"))
 167                {
 80168                    authentication = AuthenticationMechanism.DeserializeAuthenticationMechanism(property.Value);
 80169                    continue;
 170                }
 144171                if (property.NameEquals("capabilities"))
 172                {
 80173                    capabilities = DeviceCapabilities.DeserializeDeviceCapabilities(property.Value);
 80174                    continue;
 175                }
 64176                if (property.NameEquals("deviceScope"))
 177                {
 0178                    deviceScope = property.Value.GetString();
 0179                    continue;
 180                }
 64181                if (property.NameEquals("parentScopes"))
 182                {
 64183                    List<string> array = new List<string>();
 0184                    foreach (var item in property.Value.EnumerateArray())
 185                    {
 0186                        array.Add(item.GetString());
 187                    }
 64188                    parentScopes = array;
 189                    continue;
 190                }
 191            }
 80192            return new DeviceIdentity(deviceId.Value, generationId.Value, etag.Value, Optional.ToNullable(connectionStat
 193        }
 194    }
 195}