< Summary

Class:Azure.ResourceManager.Resources.Models.PolicyDefinitionReference
Assembly:Azure.ResourceManager.Resources
File(s):C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\PolicyDefinitionReference.cs
C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\PolicyDefinitionReference.Serialization.cs
Covered lines:63
Uncovered lines:3
Coverable lines:66
Total lines:168
Line coverage:95.4% (63 of 66)
Covered branches:33
Total branches:36
Branch coverage:91.6% (33 of 36)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-80%50%
.ctor(...)-100%100%
get_PolicyDefinitionId()-100%100%
get_Parameters()-100%100%
get_PolicyDefinitionReferenceId()-100%100%
get_GroupNames()-100%100%
Azure.Core.IUtf8JsonSerializable.Write(...)-100%100%
DeserializePolicyDefinitionReference(...)-93.33%91.67%

File(s)

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\PolicyDefinitionReference.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.Resources.Models
 12{
 13    /// <summary> The policy definition reference. </summary>
 14    public partial class PolicyDefinitionReference
 15    {
 16        /// <summary> Initializes a new instance of PolicyDefinitionReference. </summary>
 17        /// <param name="policyDefinitionId"> The ID of the policy definition or policy set definition. </param>
 2818        public PolicyDefinitionReference(string policyDefinitionId)
 19        {
 2820            if (policyDefinitionId == null)
 21            {
 022                throw new ArgumentNullException(nameof(policyDefinitionId));
 23            }
 24
 2825            PolicyDefinitionId = policyDefinitionId;
 2826        }
 27
 28        /// <summary> Initializes a new instance of PolicyDefinitionReference. </summary>
 29        /// <param name="policyDefinitionId"> The ID of the policy definition or policy set definition. </param>
 30        /// <param name="parameters"> The parameter values for the referenced policy rule. The keys are the parameter na
 31        /// <param name="policyDefinitionReferenceId"> A unique id (within the policy set definition) for this policy de
 32        /// <param name="groupNames"> The name of the groups that this policy definition reference belongs to. </param>
 6677233        internal PolicyDefinitionReference(string policyDefinitionId, IDictionary<string, ParameterValuesValue> paramete
 34        {
 6677235            PolicyDefinitionId = policyDefinitionId;
 6677236            Parameters = parameters;
 6677237            PolicyDefinitionReferenceId = policyDefinitionReferenceId;
 6677238            GroupNames = groupNames;
 6677239        }
 40
 41        /// <summary> The ID of the policy definition or policy set definition. </summary>
 1196221642        public string PolicyDefinitionId { get; set; }
 43        /// <summary> The parameter values for the referenced policy rule. The keys are the parameter names. </summary>
 6682444        public IDictionary<string, ParameterValuesValue> Parameters { get; set; }
 45        /// <summary> A unique id (within the policy set definition) for this policy definition reference. </summary>
 11751646        public string PolicyDefinitionReferenceId { get; set; }
 47        /// <summary> The name of the groups that this policy definition reference belongs to. </summary>
 10036048        public IList<string> GroupNames { get; set; }
 49    }
 50}

C:\Git\azure-sdk-for-net\sdk\resources\Azure.ResourceManager.Resources\src\Generated\Models\PolicyDefinitionReference.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 PolicyDefinitionReference : IUtf8JsonSerializable
 15    {
 16        void IUtf8JsonSerializable.Write(Utf8JsonWriter writer)
 17        {
 3618            writer.WriteStartObject();
 3619            writer.WritePropertyName("policyDefinitionId");
 3620            writer.WriteStringValue(PolicyDefinitionId);
 3621            if (Parameters != null)
 22            {
 823                writer.WritePropertyName("parameters");
 824                writer.WriteStartObject();
 3225                foreach (var item in Parameters)
 26                {
 827                    writer.WritePropertyName(item.Key);
 828                    writer.WriteObjectValue(item.Value);
 29                }
 830                writer.WriteEndObject();
 31            }
 3632            if (PolicyDefinitionReferenceId != null)
 33            {
 834                writer.WritePropertyName("policyDefinitionReferenceId");
 835                writer.WriteStringValue(PolicyDefinitionReferenceId);
 36            }
 3637            if (GroupNames != null)
 38            {
 839                writer.WritePropertyName("groupNames");
 840                writer.WriteStartArray();
 4041                foreach (var item in GroupNames)
 42                {
 1243                    writer.WriteStringValue(item);
 44                }
 845                writer.WriteEndArray();
 46            }
 3647            writer.WriteEndObject();
 3648        }
 49
 50        internal static PolicyDefinitionReference DeserializePolicyDefinitionReference(JsonElement element)
 51        {
 6677252            string policyDefinitionId = default;
 6677253            IDictionary<string, ParameterValuesValue> parameters = default;
 6677254            string policyDefinitionReferenceId = default;
 6677255            IList<string> groupNames = default;
 59575256            foreach (var property in element.EnumerateObject())
 57            {
 23110458                if (property.NameEquals("policyDefinitionId"))
 59                {
 6677260                    policyDefinitionId = property.Value.GetString();
 6677261                    continue;
 62                }
 16433263                if (property.NameEquals("parameters"))
 64                {
 6410465                    if (property.Value.ValueKind == JsonValueKind.Null)
 66                    {
 67                        continue;
 68                    }
 6410469                    Dictionary<string, ParameterValuesValue> dictionary = new Dictionary<string, ParameterValuesValue>()
 16464070                    foreach (var property0 in property.Value.EnumerateObject())
 71                    {
 1821672                        if (property0.Value.ValueKind == JsonValueKind.Null)
 73                        {
 074                            dictionary.Add(property0.Name, null);
 75                        }
 76                        else
 77                        {
 1821678                            dictionary.Add(property0.Name, ParameterValuesValue.DeserializeParameterValuesValue(property
 79                        }
 80                    }
 6410481                    parameters = dictionary;
 6410482                    continue;
 83                }
 10022884                if (property.NameEquals("policyDefinitionReferenceId"))
 85                {
 6677286                    if (property.Value.ValueKind == JsonValueKind.Null)
 87                    {
 88                        continue;
 89                    }
 6677290                    policyDefinitionReferenceId = property.Value.GetString();
 6677291                    continue;
 92                }
 3345693                if (property.NameEquals("groupNames"))
 94                {
 3345695                    if (property.Value.ValueKind == JsonValueKind.Null)
 96                    {
 97                        continue;
 98                    }
 3345699                    List<string> array = new List<string>();
 139216100                    foreach (var item in property.Value.EnumerateArray())
 101                    {
 36152102                        if (item.ValueKind == JsonValueKind.Null)
 103                        {
 0104                            array.Add(null);
 105                        }
 106                        else
 107                        {
 36152108                            array.Add(item.GetString());
 109                        }
 110                    }
 33456111                    groupNames = array;
 112                    continue;
 113                }
 114            }
 66772115            return new PolicyDefinitionReference(policyDefinitionId, parameters, policyDefinitionReferenceId, groupNames
 116        }
 117    }
 118}