< Summary

Class:Azure.Iot.Hub.Service.Models.TwinData
Assembly:Azure.Iot.Hub.Service
File(s):C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\TwinData.cs
C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\TwinData.Serialization.cs
Covered lines:155
Uncovered lines:30
Coverable lines:185
Total lines:352
Line coverage:83.7% (155 of 185)
Covered branches:64
Total branches:82
Branch coverage:78% (64 of 82)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-100%100%
get_DeviceId()-100%100%
get_ModuleId()-100%100%
get_Tags()-100%100%
get_Properties()-100%100%
get_Etag()-100%100%
get_Version()-100%100%
get_DeviceEtag()-100%100%
get_Status()-100%100%
get_StatusReason()-100%100%
get_StatusUpdateTime()-100%100%
get_ConnectionState()-100%100%
get_LastActivityTime()-100%100%
get_CloudToDeviceMessageCount()-100%100%
get_AuthenticationType()-100%100%
get_X509Thumbprint()-100%100%
get_Capabilities()-100%100%
get_DeviceScope()-100%100%
get_ParentScopes()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-76.56%80%
DeserializeTwinData(...)-81.01%76.19%

File(s)

C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\TwinData.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 state information for a device or module. This is implicitly created and deleted when the correspo
 15    public partial class TwinData
 16    {
 17        /// <summary> Initializes a new instance of TwinData. </summary>
 8018        public TwinData()
 19        {
 8020            Tags = new ChangeTrackingDictionary<string, object>();
 8021            ParentScopes = new ChangeTrackingList<string>();
 8022        }
 23
 24        /// <summary> Initializes a new instance of TwinData. </summary>
 25        /// <param name="deviceId"> The unique identifier of the device in the identity registry of the IoT Hub. It is a
 26        /// <param name="moduleId"> The unique identifier of the module in the identity registry of the IoT Hub. It is a
 27        /// <param name="tags"> The collection of key-value pairs read and written by the solution back end. They are no
 28        /// <param name="properties"> The desired and reported properties of the twin. </param>
 29        /// <param name="etag"> The string representing a ETag for the device twin, as per RFC7232. </param>
 30        /// <param name="version"> The version for the device twin including tags and desired properties. </param>
 31        /// <param name="deviceEtag"> The string representing a ETag for the device, as per RFC7232. </param>
 32        /// <param name="status"> The enabled status of the device. If disabled, the device cannot connect to the servic
 33        /// <param name="statusReason"> The reason for the current status of the device, if any. </param>
 34        /// <param name="statusUpdateTime"> The date and time when the status of the device was last updated. </param>
 35        /// <param name="connectionState"> The connection state of the device. </param>
 36        /// <param name="lastActivityTime"> The date and time when the device last connected or received or sent a messa
 37        /// <param name="cloudToDeviceMessageCount"> The number of cloud-to-device messages sent. </param>
 38        /// <param name="authenticationType"> The authentication type used by the device. </param>
 39        /// <param name="x509Thumbprint"> The X509 thumbprint of the device. </param>
 40        /// <param name="capabilities"> The status of capabilities enabled on the device. </param>
 41        /// <param name="deviceScope"> The scope of the device. </param>
 42        /// <param name="parentScopes"> The scopes of the upper level edge devices if applicable. Only available for edg
 25043        internal TwinData(string deviceId, string moduleId, IDictionary<string, object> tags, TwinProperties properties,
 44        {
 25045            DeviceId = deviceId;
 25046            ModuleId = moduleId;
 25047            Tags = tags;
 25048            Properties = properties;
 25049            Etag = etag;
 25050            Version = version;
 25051            DeviceEtag = deviceEtag;
 25052            Status = status;
 25053            StatusReason = statusReason;
 25054            StatusUpdateTime = statusUpdateTime;
 25055            ConnectionState = connectionState;
 25056            LastActivityTime = lastActivityTime;
 25057            CloudToDeviceMessageCount = cloudToDeviceMessageCount;
 25058            AuthenticationType = authenticationType;
 25059            X509Thumbprint = x509Thumbprint;
 25060            Capabilities = capabilities;
 25061            DeviceScope = deviceScope;
 25062            ParentScopes = parentScopes;
 25063        }
 64
 65        /// <summary> The unique identifier of the device in the identity registry of the IoT Hub. It is a case-sensitiv
 188666        public string DeviceId { get; set; }
 67        /// <summary> The unique identifier of the module in the identity registry of the IoT Hub. It is a case-sensitiv
 29868        public string ModuleId { get; set; }
 69        /// <summary> The collection of key-value pairs read and written by the solution back end. They are not visible 
 9670        public IDictionary<string, object> Tags { get; }
 71        /// <summary> The desired and reported properties of the twin. </summary>
 47472        public TwinProperties Properties { get; set; }
 73        /// <summary> The string representing a ETag for the device twin, as per RFC7232. </summary>
 29874        public string Etag { get; set; }
 75        /// <summary> The version for the device twin including tags and desired properties. </summary>
 28276        public long? Version { get; set; }
 77        /// <summary> The string representing a ETag for the device, as per RFC7232. </summary>
 28278        public string DeviceEtag { get; set; }
 79        /// <summary> The enabled status of the device. If disabled, the device cannot connect to the service. </summary
 28280        public TwinStatus? Status { get; set; }
 81        /// <summary> The reason for the current status of the device, if any. </summary>
 26682        public string StatusReason { get; set; }
 83        /// <summary> The date and time when the status of the device was last updated. </summary>
 28284        public DateTimeOffset? StatusUpdateTime { get; set; }
 85        /// <summary> The connection state of the device. </summary>
 28286        public TwinConnectionState? ConnectionState { get; set; }
 87        /// <summary> The date and time when the device last connected or received or sent a message. The date and time 
 28288        public DateTimeOffset? LastActivityTime { get; set; }
 89        /// <summary> The number of cloud-to-device messages sent. </summary>
 28290        public int? CloudToDeviceMessageCount { get; set; }
 91        /// <summary> The authentication type used by the device. </summary>
 28292        public TwinAuthenticationType? AuthenticationType { get; set; }
 93        /// <summary> The X509 thumbprint of the device. </summary>
 28294        public X509Thumbprint X509Thumbprint { get; set; }
 95        /// <summary> The status of capabilities enabled on the device. </summary>
 27096        public DeviceCapabilities Capabilities { get; set; }
 97        /// <summary> The scope of the device. </summary>
 26698        public string DeviceScope { get; set; }
 99        /// <summary> The scopes of the upper level edge devices if applicable. Only available for edge devices. </summa
 16100        public IList<string> ParentScopes { get; }
 101    }
 102}

C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\TwinData.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 TwinData : IUtf8JsonSerializable
 16    {
 17        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 18        {
 1619            writer.WriteStartObject();
 1620            if (Optional.IsDefined(DeviceId))
 21            {
 1622                writer.WritePropertyName("deviceId");
 1623                writer.WriteStringValue(DeviceId);
 24            }
 1625            if (Optional.IsDefined(ModuleId))
 26            {
 1227                writer.WritePropertyName("moduleId");
 1228                writer.WriteStringValue(ModuleId);
 29            }
 1630            if (Optional.IsCollectionDefined(Tags))
 31            {
 032                writer.WritePropertyName("tags");
 033                writer.WriteStartObject();
 034                foreach (var item in Tags)
 35                {
 036                    writer.WritePropertyName(item.Key);
 037                    writer.WriteObjectValue(item.Value);
 38                }
 039                writer.WriteEndObject();
 40            }
 1641            if (Optional.IsDefined(Properties))
 42            {
 1643                writer.WritePropertyName("properties");
 1644                writer.WriteObjectValue(Properties);
 45            }
 1646            if (Optional.IsDefined(Etag))
 47            {
 1648                writer.WritePropertyName("etag");
 1649                writer.WriteStringValue(Etag);
 50            }
 1651            if (Optional.IsDefined(Version))
 52            {
 1653                writer.WritePropertyName("version");
 1654                writer.WriteNumberValue(Version.Value);
 55            }
 1656            if (Optional.IsDefined(DeviceEtag))
 57            {
 1658                writer.WritePropertyName("deviceEtag");
 1659                writer.WriteStringValue(DeviceEtag);
 60            }
 1661            if (Optional.IsDefined(Status))
 62            {
 1663                writer.WritePropertyName("status");
 1664                writer.WriteStringValue(Status.Value.ToString());
 65            }
 1666            if (Optional.IsDefined(StatusReason))
 67            {
 068                writer.WritePropertyName("statusReason");
 069                writer.WriteStringValue(StatusReason);
 70            }
 1671            if (Optional.IsDefined(StatusUpdateTime))
 72            {
 1673                writer.WritePropertyName("statusUpdateTime");
 1674                writer.WriteStringValue(StatusUpdateTime.Value, "O");
 75            }
 1676            if (Optional.IsDefined(ConnectionState))
 77            {
 1678                writer.WritePropertyName("connectionState");
 1679                writer.WriteStringValue(ConnectionState.Value.ToString());
 80            }
 1681            if (Optional.IsDefined(LastActivityTime))
 82            {
 1683                writer.WritePropertyName("lastActivityTime");
 1684                writer.WriteStringValue(LastActivityTime.Value, "O");
 85            }
 1686            if (Optional.IsDefined(CloudToDeviceMessageCount))
 87            {
 1688                writer.WritePropertyName("cloudToDeviceMessageCount");
 1689                writer.WriteNumberValue(CloudToDeviceMessageCount.Value);
 90            }
 1691            if (Optional.IsDefined(AuthenticationType))
 92            {
 1693                writer.WritePropertyName("authenticationType");
 1694                writer.WriteStringValue(AuthenticationType.Value.ToString());
 95            }
 1696            if (Optional.IsDefined(X509Thumbprint))
 97            {
 1698                writer.WritePropertyName("x509Thumbprint");
 1699                writer.WriteObjectValue(X509Thumbprint);
 100            }
 16101            if (Optional.IsDefined(Capabilities))
 102            {
 4103                writer.WritePropertyName("capabilities");
 4104                writer.WriteObjectValue(Capabilities);
 105            }
 16106            if (Optional.IsDefined(DeviceScope))
 107            {
 0108                writer.WritePropertyName("deviceScope");
 0109                writer.WriteStringValue(DeviceScope);
 110            }
 16111            if (Optional.IsCollectionDefined(ParentScopes))
 112            {
 0113                writer.WritePropertyName("parentScopes");
 0114                writer.WriteStartArray();
 0115                foreach (var item in ParentScopes)
 116                {
 0117                    writer.WriteStringValue(item);
 118                }
 0119                writer.WriteEndArray();
 120            }
 16121            writer.WriteEndObject();
 16122        }
 123
 124        internal static TwinData DeserializeTwinData(JsonElement element)
 125        {
 250126            Optional<string> deviceId = default;
 250127            Optional<string> moduleId = default;
 250128            Optional<IDictionary<string, object>> tags = default;
 250129            Optional<TwinProperties> properties = default;
 250130            Optional<string> etag = default;
 250131            Optional<long> version = default;
 250132            Optional<string> deviceEtag = default;
 250133            Optional<TwinStatus> status = default;
 250134            Optional<string> statusReason = default;
 250135            Optional<DateTimeOffset> statusUpdateTime = default;
 250136            Optional<TwinConnectionState> connectionState = default;
 250137            Optional<DateTimeOffset> lastActivityTime = default;
 250138            Optional<int> cloudToDeviceMessageCount = default;
 250139            Optional<TwinAuthenticationType> authenticationType = default;
 250140            Optional<X509Thumbprint> x509Thumbprint = default;
 250141            Optional<DeviceCapabilities> capabilities = default;
 250142            Optional<string> deviceScope = default;
 250143            Optional<IList<string>> parentScopes = default;
 7224144            foreach (var property in element.EnumerateObject())
 145            {
 3362146                if (property.NameEquals("deviceId"))
 147                {
 250148                    deviceId = property.Value.GetString();
 250149                    continue;
 150                }
 3112151                if (property.NameEquals("moduleId"))
 152                {
 132153                    moduleId = property.Value.GetString();
 132154                    continue;
 155                }
 2980156                if (property.NameEquals("tags"))
 157                {
 0158                    Dictionary<string, object> dictionary = new Dictionary<string, object>();
 0159                    foreach (var property0 in property.Value.EnumerateObject())
 160                    {
 0161                        dictionary.Add(property0.Name, property0.Value.GetObject());
 162                    }
 0163                    tags = dictionary;
 0164                    continue;
 165                }
 2980166                if (property.NameEquals("properties"))
 167                {
 250168                    properties = TwinProperties.DeserializeTwinProperties(property.Value);
 250169                    continue;
 170                }
 2730171                if (property.NameEquals("etag"))
 172                {
 250173                    etag = property.Value.GetString();
 250174                    continue;
 175                }
 2480176                if (property.NameEquals("version"))
 177                {
 250178                    version = property.Value.GetInt64();
 250179                    continue;
 180                }
 2230181                if (property.NameEquals("deviceEtag"))
 182                {
 250183                    deviceEtag = property.Value.GetString();
 250184                    continue;
 185                }
 1980186                if (property.NameEquals("status"))
 187                {
 250188                    status = new TwinStatus(property.Value.GetString());
 250189                    continue;
 190                }
 1730191                if (property.NameEquals("statusReason"))
 192                {
 0193                    statusReason = property.Value.GetString();
 0194                    continue;
 195                }
 1730196                if (property.NameEquals("statusUpdateTime"))
 197                {
 250198                    statusUpdateTime = property.Value.GetDateTimeOffset("O");
 250199                    continue;
 200                }
 1480201                if (property.NameEquals("connectionState"))
 202                {
 250203                    connectionState = new TwinConnectionState(property.Value.GetString());
 250204                    continue;
 205                }
 1230206                if (property.NameEquals("lastActivityTime"))
 207                {
 250208                    lastActivityTime = property.Value.GetDateTimeOffset("O");
 250209                    continue;
 210                }
 980211                if (property.NameEquals("cloudToDeviceMessageCount"))
 212                {
 250213                    cloudToDeviceMessageCount = property.Value.GetInt32();
 250214                    continue;
 215                }
 730216                if (property.NameEquals("authenticationType"))
 217                {
 250218                    authenticationType = new TwinAuthenticationType(property.Value.GetString());
 250219                    continue;
 220                }
 480221                if (property.NameEquals("x509Thumbprint"))
 222                {
 250223                    x509Thumbprint = X509Thumbprint.DeserializeX509Thumbprint(property.Value);
 250224                    continue;
 225                }
 230226                if (property.NameEquals("capabilities"))
 227                {
 230228                    capabilities = DeviceCapabilities.DeserializeDeviceCapabilities(property.Value);
 230229                    continue;
 230                }
 0231                if (property.NameEquals("deviceScope"))
 232                {
 0233                    deviceScope = property.Value.GetString();
 0234                    continue;
 235                }
 0236                if (property.NameEquals("parentScopes"))
 237                {
 0238                    List<string> array = new List<string>();
 0239                    foreach (var item in property.Value.EnumerateArray())
 240                    {
 0241                        array.Add(item.GetString());
 242                    }
 0243                    parentScopes = array;
 244                    continue;
 245                }
 246            }
 250247            return new TwinData(deviceId.Value, moduleId.Value, Optional.ToDictionary(tags), properties.Value, etag.Valu
 248        }
 249    }
 250}