< Summary

Class:Azure.Iot.Hub.Service.ExportImportDeviceExtensions
Assembly:Azure.Iot.Hub.Service
File(s):C:\Git\azure-sdk-for-net\sdk\iot\Azure.Iot.Hub.Service\src\ExportImportDeviceExtensions.cs
Covered lines:8
Uncovered lines:6
Coverable lines:14
Total lines:62
Line coverage:57.1% (8 of 14)
Covered branches:7
Total branches:10
Branch coverage:70% (7 of 10)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
WithTags(...)-33.33%50%
WithPropertiesFrom(...)-75%83.33%
WithParentScopes(...)-33.33%50%

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System.Collections.Generic;
 5using Azure.Iot.Hub.Service.Models;
 6
 7namespace Azure.Iot.Hub.Service
 8{
 9    /// <summary>
 10    /// Helper functions for mutating the <see cref="ExportImportDevice"/> instance.
 11    /// </summary>
 12    internal static class ExportImportDeviceExtensions
 13    {
 14        /// <summary>
 15        /// Initializes the <see cref="ExportImportDevice.Tags"/> property using provided values.
 16        /// </summary>
 17        public static ExportImportDevice WithTags(this ExportImportDevice device, IDictionary<string, object> tags)
 18        {
 019            foreach (var tag in tags)
 20            {
 021                device.Tags.Add(tag);
 22            }
 8023            return device;
 24        }
 25
 26        /// <summary>
 27        /// Initializes the <see cref="ExportImportDevice.Properties"/> property using provided values.
 28        /// </summary>
 29        public static ExportImportDevice WithPropertiesFrom(this ExportImportDevice device, TwinProperties properties)
 30        {
 31
 8032            var container = new PropertyContainer();
 8033            if (properties != null)
 34            {
 32035                foreach (var property in properties.Desired)
 36                {
 8037                    container.Desired.Add(property);
 38                }
 039                foreach (var property in properties.Reported)
 40                {
 041                    container.Reported.Add(property);
 42                }
 43            }
 44
 8045            device.Properties = container;
 46
 8047            return device;
 48        }
 49
 50        /// <summary>
 51        /// Initializes the <see cref="ExportImportDevice.ParentScopes"/> property using provided values.
 52        /// </summary>
 53        public static ExportImportDevice WithParentScopes(this ExportImportDevice device, IList<string> parentScopes)
 54        {
 055            foreach (var parentScope in parentScopes)
 56            {
 057                device.ParentScopes.Add(parentScope);
 58            }
 16859            return device;
 60        }
 61    }
 62}