< Summary

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

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor()-100%100%
get_Email()-100%100%
get_FirstName()-100%100%
get_LastName()-100%100%
get_Phone()-100%100%
ReadProperties(...)-100%100%
.cctor()-100%100%
WriteProperties(...)-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Certificates\src\AdministratorContact.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    /// Details of an administrator of a <see cref="CertificateIssuer"/>.
 10    /// </summary>
 11    public class AdministratorContact
 12    {
 13        /// <summary>
 14        /// Initializes a new instance of the <see cref="AdministratorContact"/> class.
 15        /// </summary>
 1816        public AdministratorContact()
 17        {
 1818        }
 19
 20        /// <summary>
 21        /// Gets or sets the email address of the administrator.
 22        /// </summary>
 3623        public string Email { get; set; }
 24
 25        /// <summary>
 26        /// Gets or sets the first name of the administrator.
 27        /// </summary>
 3628        public string FirstName { get; set; }
 29
 30        /// <summary>
 31        /// Gets or sets the last name of the administrator.
 32        /// </summary>
 3633        public string LastName { get; set; }
 34
 35        /// <summary>
 36        /// Gets or sets the phone number of the administrator.
 37        /// </summary>
 3638        public string Phone { get; set; }
 39
 40        private const string FirstNamePropertyName = "first_name";
 41        private const string LastNamePropertyName = "last_name";
 42        private const string EmailPropertyName = "email";
 43        private const string PhonePropertyName = "phone";
 44
 45        internal void ReadProperties(JsonElement json)
 46        {
 12047            foreach (JsonProperty prop in json.EnumerateObject())
 48            {
 4849                switch (prop.Name)
 50                {
 51                    case FirstNamePropertyName:
 1252                        FirstName = prop.Value.GetString();
 1253                        break;
 54                    case LastNamePropertyName:
 1255                        LastName = prop.Value.GetString();
 1256                        break;
 57                    case EmailPropertyName:
 1258                        Email = prop.Value.GetString();
 1259                        break;
 60                    case PhonePropertyName:
 1261                        Phone = prop.Value.GetString();
 62                        break;
 63                }
 64            }
 1265        }
 66
 267        private static readonly JsonEncodedText s_firstNamePropertyNameBytes = JsonEncodedText.Encode(FirstNamePropertyN
 268        private static readonly JsonEncodedText s_lastNamePropertyNameBytes = JsonEncodedText.Encode(LastNamePropertyNam
 269        private static readonly JsonEncodedText s_emailPropertyNameBytes = JsonEncodedText.Encode(EmailPropertyName);
 270        private static readonly JsonEncodedText s_phonePropertyNameBytes = JsonEncodedText.Encode(PhonePropertyName);
 71
 72        internal void WriteProperties(Utf8JsonWriter json)
 73        {
 674            if (!string.IsNullOrEmpty(FirstName))
 75            {
 676                json.WriteString(s_firstNamePropertyNameBytes, FirstName);
 77            }
 78
 679            if (!string.IsNullOrEmpty(LastName))
 80            {
 681                json.WriteString(s_lastNamePropertyNameBytes, LastName);
 82            }
 83
 684            if (!string.IsNullOrEmpty(Email))
 85            {
 686                json.WriteString(s_emailPropertyNameBytes, Email);
 87            }
 88
 689            if (!string.IsNullOrEmpty(Phone))
 90            {
 691                json.WriteString(s_phonePropertyNameBytes, Phone);
 92            }
 693        }
 94    }
 95}