< Summary

Class:Azure.ResourceManager.DigitalTwins.Models.DigitalTwinsResource
Assembly:Azure.ResourceManager.DigitalTwins
File(s):C:\Git\azure-sdk-for-net\sdk\digitaltwins\Azure.ResourceManager.DigitalTwins\src\Generated\Models\DigitalTwinsResource.cs
C:\Git\azure-sdk-for-net\sdk\digitaltwins\Azure.ResourceManager.DigitalTwins\src\Generated\Models\DigitalTwinsResource.Serialization.cs
Covered lines:18
Uncovered lines:50
Coverable lines:68
Total lines:162
Line coverage:26.4% (18 of 68)
Covered branches:1
Total branches:28
Branch coverage:3.5% (1 of 28)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-83.33%50%
.ctor(...)-100%100%
get_Id()-100%100%
get_Name()-100%100%
get_Type()-0%100%
get_Location()-100%100%
get_Tags()-100%100%
get_Sku()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-0%0%
DeserializeDigitalTwinsResource(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\digitaltwins\Azure.ResourceManager.DigitalTwins\src\Generated\Models\DigitalTwinsResource.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.ResourceManager.DigitalTwins.Models
 13{
 14    /// <summary> The common properties of a DigitalTwinsInstance. </summary>
 15    public partial class DigitalTwinsResource
 16    {
 17        /// <summary> Initializes a new instance of DigitalTwinsResource. </summary>
 18        /// <param name="location"> The resource location. </param>
 19        /// <exception cref="ArgumentNullException"> <paramref name="location"/> is null. </exception>
 420        public DigitalTwinsResource(string location)
 21        {
 422            if (location == null)
 23            {
 024                throw new ArgumentNullException(nameof(location));
 25            }
 26
 427            Location = location;
 428            Tags = new ChangeTrackingDictionary<string, string>();
 429        }
 30
 31        /// <summary> Initializes a new instance of DigitalTwinsResource. </summary>
 32        /// <param name="id"> The resource identifier. </param>
 33        /// <param name="name"> The resource name. </param>
 34        /// <param name="type"> The resource type. </param>
 35        /// <param name="location"> The resource location. </param>
 36        /// <param name="tags"> The resource tags. </param>
 37        /// <param name="sku"> This property is reserved for future use, and will be ignored/omitted. </param>
 4238        internal DigitalTwinsResource(string id, string name, string type, string location, IDictionary<string, string> 
 39        {
 4240            Id = id;
 4241            Name = name;
 4242            Type = type;
 4243            Location = location;
 4244            Tags = tags;
 4245            Sku = sku;
 4246        }
 47
 48        /// <summary> The resource identifier. </summary>
 1249        public string Id { get; }
 50        /// <summary> The resource name. </summary>
 4651        public string Name { get; }
 52        /// <summary> The resource type. </summary>
 053        public string Type { get; }
 54        /// <summary> The resource location. </summary>
 6655        public string Location { get; set; }
 56        /// <summary> The resource tags. </summary>
 5457        public IDictionary<string, string> Tags { get; set; }
 58        /// <summary> This property is reserved for future use, and will be ignored/omitted. </summary>
 5059        public DigitalTwinsSkuInfo Sku { get; set; }
 60    }
 61}

C:\Git\azure-sdk-for-net\sdk\digitaltwins\Azure.ResourceManager.DigitalTwins\src\Generated\Models\DigitalTwinsResource.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.ResourceManager.DigitalTwins.Models
 13{
 14    public partial class DigitalTwinsResource : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 018            writer.WriteStartObject();
 019            writer.WritePropertyName("location");
 020            writer.WriteStringValue(Location);
 021            if (Optional.IsCollectionDefined(Tags))
 22            {
 023                if (Tags != null)
 24                {
 025                    writer.WritePropertyName("tags");
 026                    writer.WriteStartObject();
 027                    foreach (var item in Tags)
 28                    {
 029                        writer.WritePropertyName(item.Key);
 030                        writer.WriteStringValue(item.Value);
 31                    }
 032                    writer.WriteEndObject();
 33                }
 34                else
 35                {
 036                    writer.WriteNull("tags");
 37                }
 38            }
 039            if (Optional.IsDefined(Sku))
 40            {
 041                writer.WritePropertyName("sku");
 042                writer.WriteObjectValue(Sku);
 43            }
 044            writer.WriteEndObject();
 045        }
 46
 47        internal static DigitalTwinsResource DeserializeDigitalTwinsResource(JsonElement element)
 48        {
 049            Optional<string> id = default;
 050            Optional<string> name = default;
 051            Optional<string> type = default;
 052            string location = default;
 053            Optional<IDictionary<string, string>> tags = default;
 054            Optional<DigitalTwinsSkuInfo> sku = default;
 055            foreach (var property in element.EnumerateObject())
 56            {
 057                if (property.NameEquals("id"))
 58                {
 059                    id = property.Value.GetString();
 060                    continue;
 61                }
 062                if (property.NameEquals("name"))
 63                {
 064                    name = property.Value.GetString();
 065                    continue;
 66                }
 067                if (property.NameEquals("type"))
 68                {
 069                    type = property.Value.GetString();
 070                    continue;
 71                }
 072                if (property.NameEquals("location"))
 73                {
 074                    location = property.Value.GetString();
 075                    continue;
 76                }
 077                if (property.NameEquals("tags"))
 78                {
 079                    if (property.Value.ValueKind == JsonValueKind.Null)
 80                    {
 081                        tags = null;
 082                        continue;
 83                    }
 084                    Dictionary<string, string> dictionary = new Dictionary<string, string>();
 085                    foreach (var property0 in property.Value.EnumerateObject())
 86                    {
 087                        dictionary.Add(property0.Name, property0.Value.GetString());
 88                    }
 089                    tags = dictionary;
 090                    continue;
 91                }
 092                if (property.NameEquals("sku"))
 93                {
 094                    sku = DigitalTwinsSkuInfo.DeserializeDigitalTwinsSkuInfo(property.Value);
 95                    continue;
 96                }
 97            }
 098            return new DigitalTwinsResource(id.Value, name.Value, type.Value, location, Optional.ToDictionary(tags), sku
 99        }
 100    }
 101}