< Summary

Class:Azure.Security.KeyVault.Certificates.CertificateCreateParameters
Assembly:Azure.Security.KeyVault.Certificates
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Certificates\src\CertificateCreateParameters.cs
Covered lines:19
Uncovered lines:7
Coverable lines:26
Total lines:67
Line coverage:73% (19 of 26)
Covered branches:4
Total branches:8
Branch coverage:50% (4 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.cctor()-100%100%
.ctor(...)-100%100%
get_Policy()-100%100%
get_Enabled()-100%100%
get_Tags()-100%100%
Azure.Security.KeyVault.IJsonSerializable.WriteProperties(...)-50%50%

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Certificates\src\CertificateCreateParameters.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System.Collections.Generic;
 5using System.Text.Json;
 6
 7namespace Azure.Security.KeyVault.Certificates
 8{
 9    internal class CertificateCreateParameters : IJsonSerializable
 10    {
 11        private const string PolicyPropertyName = "policy";
 12        private const string AttributesPropertyName = "attributes";
 13        private const string EnabledPropertyName = "enabled";
 14        private const string TagsPropertyName = "tags";
 15
 216        private static readonly JsonEncodedText s_policyPropertyNameBytes = JsonEncodedText.Encode(PolicyPropertyName);
 217        private static readonly JsonEncodedText s_attributesPropertyNameBytes = JsonEncodedText.Encode(AttributesPropert
 218        private static readonly JsonEncodedText s_enabledPropertyNameBytes = JsonEncodedText.Encode(EnabledPropertyName)
 219        private static readonly JsonEncodedText s_tagsPropertyNameBytes = JsonEncodedText.Encode(TagsPropertyName);
 20
 6021        public CertificateCreateParameters(CertificatePolicy policy, bool? enabled, IDictionary<string, string> tags)
 22        {
 6023            Policy = policy;
 6024            Enabled = enabled;
 6025            Tags = tags;
 6026        }
 27
 12028        public CertificatePolicy Policy { get; }
 29
 6030        public bool? Enabled { get; }
 31
 6032        public IDictionary<string, string> Tags { get; }
 33
 34        void IJsonSerializable.WriteProperties(Utf8JsonWriter json)
 35        {
 6036            if (Policy != null)
 37            {
 6038                json.WriteStartObject(s_policyPropertyNameBytes);
 39
 6040                ((IJsonSerializable)Policy).WriteProperties(json);
 41
 6042                json.WriteEndObject();
 43            }
 44
 6045            if (Enabled.HasValue)
 46            {
 047                json.WriteStartObject(s_attributesPropertyNameBytes);
 48
 049                json.WriteBoolean(s_enabledPropertyNameBytes, Enabled.Value);
 50
 051                json.WriteEndObject();
 52            }
 53
 6054            if (!Tags.IsNullOrEmpty())
 55            {
 056                json.WriteStartObject(s_tagsPropertyNameBytes);
 57
 058                foreach (KeyValuePair<string, string> kvp in Tags)
 59                {
 060                    json.WriteString(kvp.Key, kvp.Value);
 61                }
 62
 063                json.WriteEndObject();
 64            }
 6065        }
 66    }
 67}