< Summary

Class:Azure.ResourceManager.Resources.Models.Identity
Assembly:Azure.ResourceManager.Resources
File(s):C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\Identity.cs
C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\Identity.Serialization.cs
Covered lines:36
Uncovered lines:21
Coverable lines:57
Total lines:150
Line coverage:63.1% (36 of 57)
Covered branches:18
Total branches:32
Branch coverage:56.2% (18 of 32)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
.ctor(...)-100%100%
get_PrincipalId()-100%100%
get_TenantId()-100%100%
get_Type()-100%100%
get_UserAssignedIdentities()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-47.37%50%
DeserializeIdentity(...)-57.69%59.09%

File(s)

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\Identity.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;
 9
 10namespace Azure.ResourceManager.Resources.Models
 11{
 12    /// <summary> Identity for the resource. </summary>
 13    public partial class Identity
 14    {
 15        /// <summary> Initializes a new instance of Identity. </summary>
 416        public Identity()
 17        {
 418        }
 19
 20        /// <summary> Initializes a new instance of Identity. </summary>
 21        /// <param name="principalId"> The principal ID of resource identity. </param>
 22        /// <param name="tenantId"> The tenant ID of resource. </param>
 23        /// <param name="type"> The identity type. </param>
 24        /// <param name="userAssignedIdentities"> The list of user identities associated with the resource. The user ide
 425        internal Identity(string principalId, string tenantId, ResourceIdentityType? type, IDictionary<string, IdentityU
 26        {
 427            PrincipalId = principalId;
 428            TenantId = tenantId;
 429            Type = type;
 430            UserAssignedIdentities = userAssignedIdentities;
 431        }
 32
 33        /// <summary> The principal ID of resource identity. </summary>
 1234        public string PrincipalId { get; }
 35        /// <summary> The tenant ID of resource. </summary>
 836        public string TenantId { get; }
 37        /// <summary> The identity type. </summary>
 2838        public ResourceIdentityType? Type { get; set; }
 39        /// <summary> The list of user identities associated with the resource. The user identity dictionary key referen
 1240        public IDictionary<string, IdentityUserAssignedIdentitiesValue> UserAssignedIdentities { get; set; }
 41    }
 42}

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\Identity.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.Resources.Models
 13{
 14    public partial class Identity : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 818            writer.WriteStartObject();
 819            if (PrincipalId != null)
 20            {
 021                writer.WritePropertyName("principalId");
 022                writer.WriteStringValue(PrincipalId);
 23            }
 824            if (TenantId != null)
 25            {
 026                writer.WritePropertyName("tenantId");
 027                writer.WriteStringValue(TenantId);
 28            }
 829            if (Type != null)
 30            {
 831                writer.WritePropertyName("type");
 832                writer.WriteStringValue(Type.Value.ToSerialString());
 33            }
 834            if (UserAssignedIdentities != null)
 35            {
 036                writer.WritePropertyName("userAssignedIdentities");
 037                writer.WriteStartObject();
 038                foreach (var item in UserAssignedIdentities)
 39                {
 040                    writer.WritePropertyName(item.Key);
 041                    writer.WriteObjectValue(item.Value);
 42                }
 043                writer.WriteEndObject();
 44            }
 845            writer.WriteEndObject();
 846        }
 47
 48        internal static Identity DeserializeIdentity(JsonElement element)
 49        {
 450            string principalId = default;
 451            string tenantId = default;
 452            ResourceIdentityType? type = default;
 453            IDictionary<string, IdentityUserAssignedIdentitiesValue> userAssignedIdentities = default;
 2454            foreach (var property in element.EnumerateObject())
 55            {
 856                if (property.NameEquals("principalId"))
 57                {
 458                    if (property.Value.ValueKind == JsonValueKind.Null)
 59                    {
 60                        continue;
 61                    }
 462                    principalId = property.Value.GetString();
 463                    continue;
 64                }
 465                if (property.NameEquals("tenantId"))
 66                {
 067                    if (property.Value.ValueKind == JsonValueKind.Null)
 68                    {
 69                        continue;
 70                    }
 071                    tenantId = property.Value.GetString();
 072                    continue;
 73                }
 474                if (property.NameEquals("type"))
 75                {
 476                    if (property.Value.ValueKind == JsonValueKind.Null)
 77                    {
 78                        continue;
 79                    }
 480                    type = property.Value.GetString().ToResourceIdentityType();
 481                    continue;
 82                }
 083                if (property.NameEquals("userAssignedIdentities"))
 84                {
 085                    if (property.Value.ValueKind == JsonValueKind.Null)
 86                    {
 87                        continue;
 88                    }
 089                    Dictionary<string, IdentityUserAssignedIdentitiesValue> dictionary = new Dictionary<string, Identity
 090                    foreach (var property0 in property.Value.EnumerateObject())
 91                    {
 092                        if (property0.Value.ValueKind == JsonValueKind.Null)
 93                        {
 094                            dictionary.Add(property0.Name, null);
 95                        }
 96                        else
 97                        {
 098                            dictionary.Add(property0.Name, IdentityUserAssignedIdentitiesValue.DeserializeIdentityUserAs
 99                        }
 100                    }
 0101                    userAssignedIdentities = dictionary;
 102                    continue;
 103                }
 104            }
 4105            return new Identity(principalId, tenantId, type, userAssignedIdentities);
 106        }
 107    }
 108}