< Summary

Class:Azure.Iot.Hub.Service.Models.TwinProperties
Assembly:Azure.Iot.Hub.Service
File(s):C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\TwinProperties.cs
C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\TwinProperties.Serialization.cs
Covered lines:42
Uncovered lines:0
Coverable lines:42
Total lines:111
Line coverage:100% (42 of 42)
Covered branches:18
Total branches:18
Branch coverage:100% (18 of 18)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-100%100%
get_Desired()-100%100%
get_Reported()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-100%100%
DeserializeTwinProperties(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\TwinProperties.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.Collections.Generic;
 9using Azure.Core;
 10
 11namespace Azure.Iot.Hub.Service.Models
 12{
 13    /// <summary> The desired and reported properties of the twin. The maximum depth of the object is 10. </summary>
 14    public partial class TwinProperties
 15    {
 16        /// <summary> Initializes a new instance of TwinProperties. </summary>
 8017        public TwinProperties()
 18        {
 8019            Desired = new ChangeTrackingDictionary<string, object>();
 8020            Reported = new ChangeTrackingDictionary<string, object>();
 8021        }
 22
 23        /// <summary> Initializes a new instance of TwinProperties. </summary>
 24        /// <param name="desired"> The collection of desired property key-value pairs. The keys are UTF-8 encoded, case-
 25        /// <param name="reported"> The collection of reported property key-value pairs. The keys are UTF-8 encoded, cas
 25026        internal TwinProperties(IDictionary<string, object> desired, IDictionary<string, object> reported)
 27        {
 25028            Desired = desired;
 25029            Reported = reported;
 25030        }
 31
 32        /// <summary> The collection of desired property key-value pairs. The keys are UTF-8 encoded, case-sensitive and
 22433        public IDictionary<string, object> Desired { get; }
 34        /// <summary> The collection of reported property key-value pairs. The keys are UTF-8 encoded, case-sensitive an
 11235        public IDictionary<string, object> Reported { get; }
 36    }
 37}

C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\Generated\Models\TwinProperties.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.Collections.Generic;
 9using System.Text.Json;
 10using Azure.Core;
 11
 12namespace Azure.Iot.Hub.Service.Models
 13{
 14    public partial class TwinProperties : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 1618            writer.WriteStartObject();
 1619            if (Optional.IsCollectionDefined(Desired))
 20            {
 1621                writer.WritePropertyName("desired");
 1622                writer.WriteStartObject();
 12823                foreach (var item in Desired)
 24                {
 4825                    writer.WritePropertyName(item.Key);
 4826                    writer.WriteObjectValue(item.Value);
 27                }
 1628                writer.WriteEndObject();
 29            }
 1630            if (Optional.IsCollectionDefined(Reported))
 31            {
 1632                writer.WritePropertyName("reported");
 1633                writer.WriteStartObject();
 9634                foreach (var item in Reported)
 35                {
 3236                    writer.WritePropertyName(item.Key);
 3237                    writer.WriteObjectValue(item.Value);
 38                }
 1639                writer.WriteEndObject();
 40            }
 1641            writer.WriteEndObject();
 1642        }
 43
 44        internal static TwinProperties DeserializeTwinProperties(JsonElement element)
 45        {
 25046            Optional<IDictionary<string, object>> desired = default;
 25047            Optional<IDictionary<string, object>> reported = default;
 150048            foreach (var property in element.EnumerateObject())
 49            {
 50050                if (property.NameEquals("desired"))
 51                {
 25052                    Dictionary<string, object> dictionary = new Dictionary<string, object>();
 162853                    foreach (var property0 in property.Value.EnumerateObject())
 54                    {
 56455                        dictionary.Add(property0.Name, property0.Value.GetObject());
 56                    }
 25057                    desired = dictionary;
 25058                    continue;
 59                }
 25060                if (property.NameEquals("reported"))
 61                {
 25062                    Dictionary<string, object> dictionary = new Dictionary<string, object>();
 150063                    foreach (var property0 in property.Value.EnumerateObject())
 64                    {
 50065                        dictionary.Add(property0.Name, property0.Value.GetObject());
 66                    }
 25067                    reported = dictionary;
 68                    continue;
 69                }
 70            }
 25071            return new TwinProperties(Optional.ToDictionary(desired), Optional.ToDictionary(reported));
 72        }
 73    }
 74}