< Summary

Class:Azure.ResourceManager.Compute.Models.Resource
Assembly:Azure.ResourceManager.Compute
File(s):C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\src\Generated\Models\Resource.cs
C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\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\compute\Azure.ResourceManager.Compute\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.Compute.Models
 12{
 13    /// <summary> The Resource model definition. </summary>
 14    public partial class Resource
 15    {
 16        /// <summary> Initializes a new instance of Resource. </summary>
 17        /// <param name="location"> Resource location. </param>
 41618        public Resource(string location)
 19        {
 41620            if (location == null)
 21            {
 022                throw new ArgumentNullException(nameof(location));
 23            }
 24
 41625            Location = location;
 41626        }
 27
 28        /// <summary> Initializes a new instance of Resource. </summary>
 29        /// <param name="id"> Resource Id. </param>
 30        /// <param name="name"> Resource name. </param>
 31        /// <param name="type"> Resource type. </param>
 32        /// <param name="location"> Resource location. </param>
 33        /// <param name="tags"> Resource tags. </param>
 200634        internal Resource(string id, string name, string type, string location, IDictionary<string, string> tags)
 35        {
 200636            Id = id;
 200637            Name = name;
 200638            Type = type;
 200639            Location = location;
 200640            Tags = tags;
 200641        }
 42
 43        /// <summary> Resource Id. </summary>
 122444        public string Id { get; }
 45        /// <summary> Resource name. </summary>
 319246        public string Name { get; }
 47        /// <summary> Resource type. </summary>
 157648        public string Type { get; }
 49        /// <summary> Resource location. </summary>
 496650        public string Location { get; set; }
 51        /// <summary> Resource tags. </summary>
 461052        public IDictionary<string, string> Tags { get; set; }
 53    }
 54}

C:\Git\azure-sdk-for-net\sdk\compute\Azure.ResourceManager.Compute\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.Compute.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}