< Summary

Class:Azure.Security.KeyVault.Certificates.CertificateKeyType
Assembly:Azure.Security.KeyVault.Certificates
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Certificates\src\CertificateKeyType.cs
Covered lines:6
Uncovered lines:7
Coverable lines:13
Total lines:86
Line coverage:46.1% (6 of 13)
Covered branches:1
Total branches:6
Branch coverage:16.6% (1 of 6)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%50%
get_Ec()-0%100%
get_EcHsm()-0%100%
get_Rsa()-100%100%
get_RsaHsm()-0%100%
op_Equality(...)-0%100%
op_Inequality(...)-0%100%
op_Implicit(...)-100%100%
Equals(...)-0%0%
Equals(...)-100%100%
GetHashCode()-0%0%
ToString()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Certificates\src\CertificateKeyType.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 JsonWebKey key types (kty)
 11    /// </summary>
 12    public readonly struct CertificateKeyType : IEquatable<CertificateKeyType>
 13    {
 14        internal const string EcValue = "EC";
 15        internal const string EcHsmValue = "EC-HSM";
 16        internal const string RsaValue = "RSA";
 17        internal const string RsaHsmValue = "RSA-HSM";
 18
 19        private readonly string _value;
 20
 21        /// <summary>
 22        /// Initializes a new instance of the <see cref="CertificateKeyType"/> structure.
 23        /// </summary>
 24        /// <param name="value">The string value of the instance.</param>
 25        public CertificateKeyType(string value)
 26        {
 7827            _value = value ?? throw new ArgumentNullException(nameof(value));
 7828        }
 29
 30        /// <summary>
 31        /// An Elliptic Curve Cryptographic (ECC) algorithm.
 32        /// </summary>
 033        public static CertificateKeyType Ec { get; } = new CertificateKeyType(EcValue);
 34
 35        /// <summary>
 36        /// An Elliptic Curve Cryptographic (ECC) algorithm backed by HSM.
 37        /// </summary>
 038        public static CertificateKeyType EcHsm { get; } = new CertificateKeyType(EcHsmValue);
 39
 40        /// <summary>
 41        /// An RSA cryptographic algorithm.
 42        /// </summary>
 7043        public static CertificateKeyType Rsa { get; } = new CertificateKeyType(RsaValue);
 44
 45        /// <summary>
 46        /// An RSA cryptographic algorithm backed by HSM.
 47        /// </summary>
 048        public static CertificateKeyType RsaHsm { get; } = new CertificateKeyType(RsaHsmValue);
 49
 50        /// <summary>
 51        /// Determines if two <see cref="CertificateKeyType"/> values are the same.
 52        /// </summary>
 53        /// <param name="left">The first <see cref="CertificateKeyType"/> to compare.</param>
 54        /// <param name="right">The second <see cref="CertificateKeyType"/> to compare.</param>
 55        /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are the same; otherwise, false.</retur
 056        public static bool operator ==(CertificateKeyType left, CertificateKeyType right) => left.Equals(right);
 57
 58        /// <summary>
 59        /// Determines if two <see cref="CertificateKeyType"/> values are different.
 60        /// </summary>
 61        /// <param name="left">The first <see cref="CertificateKeyType"/> to compare.</param>
 62        /// <param name="right">The second <see cref="CertificateKeyType"/> to compare.</param>
 63        /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are different; otherwise, false.</retu
 064        public static bool operator !=(CertificateKeyType left, CertificateKeyType right) => !left.Equals(right);
 65
 66        /// <summary>
 67        /// Converts a string to a <see cref="CertificateKeyType"/>.
 68        /// </summary>
 69        /// <param name="value">The string value to convert.</param>
 7070        public static implicit operator CertificateKeyType(string value) => new CertificateKeyType(value);
 71
 72        /// <inheritdoc/>
 73        [EditorBrowsable(EditorBrowsableState.Never)]
 074        public override bool Equals(object obj) => obj is CertificateKeyType other && Equals(other);
 75
 76        /// <inheritdoc/>
 677        public bool Equals(CertificateKeyType other) => string.Equals(_value, other._value, StringComparison.Ordinal);
 78
 79        /// <inheritdoc/>
 80        [EditorBrowsable(EditorBrowsableState.Never)]
 081        public override int GetHashCode() => _value?.GetHashCode() ?? 0;
 82
 83        /// <inheritdoc/>
 5684        public override string ToString() => _value;
 85    }
 86}