< Summary

Class:Azure.ResourceManager.AppConfiguration.Models.Resource
Assembly:Azure.ResourceManager.AppConfiguration
File(s):C:\Git\azure-sdk-for-net\sdk\appconfiguration\Azure.ResourceManager.AppConfiguration\src\Generated\Models\Resource.cs
C:\Git\azure-sdk-for-net\sdk\appconfiguration\Azure.ResourceManager.AppConfiguration\src\Generated\Models\Resource.Serialization.cs
Covered lines:16
Uncovered lines:52
Coverable lines:68
Total lines:170
Line coverage:23.5% (16 of 68)
Covered branches:1
Total branches:36
Branch coverage:2.7% (1 of 36)

Metrics

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

File(s)

C:\Git\azure-sdk-for-net\sdk\appconfiguration\Azure.ResourceManager.AppConfiguration\src\Generated\Models\Resource.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;
 10
 11namespace Azure.ResourceManager.AppConfiguration.Models
 12{
 13    /// <summary> An Azure resource. </summary>
 14    public partial class Resource
 15    {
 16        /// <summary> Initializes a new instance of Resource. </summary>
 17        /// <param name="location"> The location of the resource. This cannot be changed after the resource is created. 
 818        public Resource(string location)
 19        {
 820            if (location == null)
 21            {
 022                throw new ArgumentNullException(nameof(location));
 23            }
 24
 825            Location = location;
 826        }
 27
 28        /// <summary> Initializes a new instance of Resource. </summary>
 29        /// <param name="id"> The resource ID. </param>
 30        /// <param name="name"> The name of the resource. </param>
 31        /// <param name="type"> The type of the resource. </param>
 32        /// <param name="location"> The location of the resource. This cannot be changed after the resource is created. 
 33        /// <param name="tags"> The tags of the resource. </param>
 2434        internal Resource(string id, string name, string type, string location, IDictionary<string, string> tags)
 35        {
 2436            Id = id;
 2437            Name = name;
 2438            Type = type;
 2439            Location = location;
 2440            Tags = tags;
 2441        }
 42
 43        /// <summary> The resource ID. </summary>
 2044        public string Id { get; }
 45        /// <summary> The name of the resource. </summary>
 1646        public string Name { get; }
 47        /// <summary> The type of the resource. </summary>
 1648        public string Type { get; }
 49        /// <summary> The location of the resource. This cannot be changed after the resource is created. </summary>
 4850        public string Location { get; set; }
 51        /// <summary> The tags of the resource. </summary>
 4052        public IDictionary<string, string> Tags { get; set; }
 53    }
 54}

C:\Git\azure-sdk-for-net\sdk\appconfiguration\Azure.ResourceManager.AppConfiguration\src\Generated\Models\Resource.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.AppConfiguration.Models
 13{
 14    public partial class Resource : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 018            writer.WriteStartObject();
 019            if (Id != null)
 20            {
 021                writer.WritePropertyName("id");
 022                writer.WriteStringValue(Id);
 23            }
 024            if (Name != null)
 25            {
 026                writer.WritePropertyName("name");
 027                writer.WriteStringValue(Name);
 28            }
 029            if (Type != null)
 30            {
 031                writer.WritePropertyName("type");
 032                writer.WriteStringValue(Type);
 33            }
 034            writer.WritePropertyName("location");
 035            writer.WriteStringValue(Location);
 036            if (Tags != null)
 37            {
 038                writer.WritePropertyName("tags");
 039                writer.WriteStartObject();
 040                foreach (var item in Tags)
 41                {
 042                    writer.WritePropertyName(item.Key);
 043                    writer.WriteStringValue(item.Value);
 44                }
 045                writer.WriteEndObject();
 46            }
 047            writer.WriteEndObject();
 048        }
 49
 50        internal static Resource DeserializeResource(JsonElement element)
 51        {
 052            string id = default;
 053            string name = default;
 054            string type = default;
 055            string location = default;
 056            IDictionary<string, string> tags = default;
 057            foreach (var property in element.EnumerateObject())
 58            {
 059                if (property.NameEquals("id"))
 60                {
 061                    if (property.Value.ValueKind == JsonValueKind.Null)
 62                    {
 63                        continue;
 64                    }
 065                    id = property.Value.GetString();
 066                    continue;
 67                }
 068                if (property.NameEquals("name"))
 69                {
 070                    if (property.Value.ValueKind == JsonValueKind.Null)
 71                    {
 72                        continue;
 73                    }
 074                    name = property.Value.GetString();
 075                    continue;
 76                }
 077                if (property.NameEquals("type"))
 78                {
 079                    if (property.Value.ValueKind == JsonValueKind.Null)
 80                    {
 81                        continue;
 82                    }
 083                    type = property.Value.GetString();
 084                    continue;
 85                }
 086                if (property.NameEquals("location"))
 87                {
 088                    location = property.Value.GetString();
 089                    continue;
 90                }
 091                if (property.NameEquals("tags"))
 92                {
 093                    if (property.Value.ValueKind == JsonValueKind.Null)
 94                    {
 95                        continue;
 96                    }
 097                    Dictionary<string, string> dictionary = new Dictionary<string, string>();
 098                    foreach (var property0 in property.Value.EnumerateObject())
 99                    {
 0100                        if (property0.Value.ValueKind == JsonValueKind.Null)
 101                        {
 0102                            dictionary.Add(property0.Name, null);
 103                        }
 104                        else
 105                        {
 0106                            dictionary.Add(property0.Name, property0.Value.GetString());
 107                        }
 108                    }
 0109                    tags = dictionary;
 110                    continue;
 111                }
 112            }
 0113            return new Resource(id, name, type, location, tags);
 114        }
 115    }
 116}