< Summary

Class:Azure.Security.KeyVault.Certificates.CertificateContact
Assembly:Azure.Security.KeyVault.Certificates
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Certificates\src\CertificateContact.cs
Covered lines:23
Uncovered lines:0
Coverable lines:23
Total lines:82
Line coverage:100% (23 of 23)
Covered branches:14
Total branches:14
Branch coverage:100% (14 of 14)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.cctor()-100%100%
.ctor()-100%100%
get_Email()-100%100%
get_Name()-100%100%
get_Phone()-100%100%
Azure.Security.KeyVault.IJsonDeserializable.ReadProperties(...)-100%100%
Azure.Security.KeyVault.IJsonSerializable.WriteProperties(...)-100%100%

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System.Text.Json;
 5
 6namespace Azure.Security.KeyVault.Certificates
 7{
 8    /// <summary>
 9    /// A contact for certificate management issues for a key vault.
 10    /// </summary>
 11    public class CertificateContact : IJsonDeserializable, IJsonSerializable
 12    {
 13        private const string NamePropertyName = "name";
 14        private const string EmailPropertyName = "email";
 15        private const string PhonePropertyName = "phone";
 16
 217        private static readonly JsonEncodedText s_namePropertyNameBytes = JsonEncodedText.Encode(NamePropertyName);
 218        private static readonly JsonEncodedText s_emailPropertyNameBytes = JsonEncodedText.Encode(EmailPropertyName);
 219        private static readonly JsonEncodedText s_phonePropertyNameBytes = JsonEncodedText.Encode(PhonePropertyName);
 20
 21        /// <summary>
 22        /// Initializes a new instance of the <see cref="CertificateContact"/> class.
 23        /// </summary>
 2424        public CertificateContact()
 25        {
 2426        }
 27
 28        /// <summary>
 29        /// Gets or sets the email address of the contact.
 30        /// </summary>
 5631        public string Email { get; set; }
 32
 33        /// <summary>
 34        /// Gets or sets the name of the contact.
 35        /// </summary>
 7236        public string Name { get; set; }
 37
 38        /// <summary>
 39        /// Gets or sets the phone number of the contact.
 40        /// </summary>
 5641        public string Phone { get; set; }
 42
 43        void IJsonDeserializable.ReadProperties(JsonElement json)
 44        {
 12845            foreach (JsonProperty prop in json.EnumerateObject())
 46            {
 4847                switch (prop.Name)
 48                {
 49                    case NamePropertyName:
 1650                        Name = prop.Value.GetString();
 1651                        break;
 52
 53                    case EmailPropertyName:
 1654                        Email = prop.Value.GetString();
 1655                        break;
 56
 57                    case PhonePropertyName:
 1658                        Phone = prop.Value.GetString();
 59                        break;
 60                }
 61            }
 1662        }
 63
 64        void IJsonSerializable.WriteProperties(Utf8JsonWriter json)
 65        {
 866            if (!string.IsNullOrEmpty(Name))
 67            {
 868                json.WriteString(s_namePropertyNameBytes, Name);
 69            }
 70
 871            if (!string.IsNullOrEmpty(Email))
 72            {
 873                json.WriteString(s_emailPropertyNameBytes, Email);
 74            }
 75
 876            if (!string.IsNullOrEmpty(Phone))
 77            {
 878                json.WriteString(s_phonePropertyNameBytes, Phone);
 79            }
 880        }
 81    }
 82}