< Summary

Class:Azure.Security.KeyVault.Certificates.CertificateKeyUsage
Assembly:Azure.Security.KeyVault.Certificates
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Certificates\src\CertificateKeyUsage.cs
Covered lines:10
Uncovered lines:8
Coverable lines:18
Total lines:116
Line coverage:55.5% (10 of 18)
Covered branches:1
Total branches:6
Branch coverage:16.6% (1 of 6)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%50%
get_DigitalSignature()-100%100%
get_NonRepudiation()-0%100%
get_KeyEncipherment()-100%100%
get_DataEncipherment()-100%100%
get_KeyAgreement()-100%100%
get_KeyCertSign()-100%100%
get_CrlSign()-100%100%
get_EncipherOnly()-0%100%
get_DecipherOnly()-0%100%
op_Equality(...)-0%100%
op_Inequality(...)-0%100%
op_Implicit(...)-100%100%
Equals(...)-0%0%
Equals(...)-0%100%
GetHashCode()-0%0%
ToString()-100%100%

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.ComponentModel;
 6
 7namespace Azure.Security.KeyVault.Certificates
 8{
 9    /// <summary>
 10    /// Supported usages of a certificate key.
 11    /// </summary>
 12    public readonly struct CertificateKeyUsage : IEquatable<CertificateKeyUsage>
 13    {
 14        internal const string DigitalSignatureValue = "digitalSignature";
 15        internal const string NonRepudiationValue = "nonRepudiation";
 16        internal const string KeyEnciphermentValue = "keyEncipherment";
 17        internal const string DataEnciphermentValue = "dataEncipherment";
 18        internal const string KeyAgreementValue = "keyAgreement";
 19        internal const string KeyCertSignValue = "keyCertSign";
 20        internal const string CrlSignValue = "crlSign";
 21        internal const string EncipherOnlyValue = "encipherOnly";
 22        internal const string DecipherOnlyValue = "decipherOnly";
 23
 24        private readonly string _value;
 25
 26        /// <summary>
 27        /// Initializes a new instance of the <see cref="CertificateKeyUsage"/> structure.
 28        /// </summary>
 29        /// <param name="value">The string value of the instance.</param>
 30        public CertificateKeyUsage(string value)
 31        {
 35032            _value = value ?? throw new ArgumentNullException(nameof(value));
 35033        }
 34
 35        /// <summary>
 36        /// Gets a <see cref="CertificateKeyUsage"/> indicating that the certificate key can be used as a digital signat
 37        /// </summary>
 6638        public static CertificateKeyUsage DigitalSignature { get; } = new CertificateKeyUsage(DigitalSignatureValue);
 39
 40        /// <summary>
 41        /// Gets a <see cref="CertificateKeyUsage"/> indicating that the certificate key can be used for authentication.
 42        /// </summary>
 043        public static CertificateKeyUsage NonRepudiation { get; } = new CertificateKeyUsage(NonRepudiationValue);
 44
 45        /// <summary>
 46        /// Gets a <see cref="CertificateKeyUsage"/> indicating that the certificate key can be used for key encryption.
 47        /// </summary>
 6648        public static CertificateKeyUsage KeyEncipherment { get; } = new CertificateKeyUsage(KeyEnciphermentValue);
 49
 50        /// <summary>
 51        /// Gets a <see cref="CertificateKeyUsage"/> indicating that the certificate key can be used for data encryption
 52        /// </summary>
 6653        public static CertificateKeyUsage DataEncipherment { get; } = new CertificateKeyUsage(DataEnciphermentValue);
 54
 55        /// <summary>
 56        /// Gets a <see cref="CertificateKeyUsage"/> indicating that the certificate key can be used to determine key ag
 57        /// </summary>
 6658        public static CertificateKeyUsage KeyAgreement { get; } = new CertificateKeyUsage(KeyAgreementValue);
 59
 60        /// <summary>
 61        /// Gets a <see cref="CertificateKeyUsage"/> indicating that the certificate key can be used to sign certificate
 62        /// </summary>
 6663        public static CertificateKeyUsage KeyCertSign { get; } = new CertificateKeyUsage(KeyCertSignValue);
 64
 65        /// <summary>
 66        /// Gets a <see cref="CertificateKeyUsage"/> indicating that the certificate key can be used to sign a certifica
 67        /// </summary>
 6668        public static CertificateKeyUsage CrlSign { get; } = new CertificateKeyUsage(CrlSignValue);
 69
 70        /// <summary>
 71        /// Gets a <see cref="CertificateKeyUsage"/> indicating that the certificate key can be used for encryption only
 72        /// </summary>
 073        public static CertificateKeyUsage EncipherOnly { get; } = new CertificateKeyUsage(EncipherOnlyValue);
 74
 75        /// <summary>
 76        /// Gets a <see cref="CertificateKeyUsage"/> indicating that the certificate key can be used for decryption only
 77        /// </summary>
 078        public static CertificateKeyUsage DecipherOnly { get; } = new CertificateKeyUsage(DecipherOnlyValue);
 79
 80        /// <summary>
 81        /// Determines if two <see cref="CertificateKeyUsage"/> values are the same.
 82        /// </summary>
 83        /// <param name="left">The first <see cref="CertificateKeyUsage"/> to compare.</param>
 84        /// <param name="right">The second <see cref="CertificateKeyUsage"/> to compare.</param>
 85        /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are the same; otherwise, false.</retur
 086        public static bool operator ==(CertificateKeyUsage left, CertificateKeyUsage right) => left.Equals(right);
 87
 88        /// <summary>
 89        /// Determines if two <see cref="CertificateKeyUsage"/> values are different.
 90        /// </summary>
 91        /// <param name="left">The first <see cref="CertificateKeyUsage"/> to compare.</param>
 92        /// <param name="right">The second <see cref="CertificateKeyUsage"/> to compare.</param>
 93        /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are different; otherwise, false.</retu
 094        public static bool operator !=(CertificateKeyUsage left, CertificateKeyUsage right) => !left.Equals(right);
 95
 96        /// <summary>
 97        /// Converts a string to a <see cref="CertificateKeyUsage"/>.
 98        /// </summary>
 99        /// <param name="value">The string value to convert.</param>
 332100        public static implicit operator CertificateKeyUsage(string value) => new CertificateKeyUsage(value);
 101
 102        /// <inheritdoc/>
 103        [EditorBrowsable(EditorBrowsableState.Never)]
 0104        public override bool Equals(object obj) => obj is CertificateKeyUsage other && Equals(other);
 105
 106        /// <inheritdoc/>
 0107        public bool Equals(CertificateKeyUsage other) => string.Equals(_value, other._value, StringComparison.Ordinal);
 108
 109        /// <inheritdoc/>
 110        [EditorBrowsable(EditorBrowsableState.Never)]
 0111        public override int GetHashCode() => _value?.GetHashCode() ?? 0;
 112
 113        /// <inheritdoc/>
 316114        public override string ToString() => _value;
 115    }
 116}