< Summary

Class:Azure.Security.KeyVault.Keys.KeyType
Assembly:Azure.Security.KeyVault.Keys
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Keys\src\KeyType.cs
Covered lines:12
Uncovered lines:2
Coverable lines:14
Total lines:86
Line coverage:85.7% (12 of 14)
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()-100%100%
get_EcHsm()-100%100%
get_Rsa()-100%100%
get_RsaHsm()-100%100%
get_Oct()-100%100%
op_Equality(...)-100%100%
op_Inequality(...)-100%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.Keys\src\KeyType.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.Keys
 8{
 9    /// <summary>
 10    /// <see cref="JsonWebKey"/> key types.
 11    /// </summary>
 12    public readonly struct KeyType : IEquatable<KeyType>
 13    {
 14        private readonly string _value;
 15
 16        /// <summary>
 17        /// Initializes a new instance of the <see cref="KeyType"/> structure.
 18        /// </summary>
 19        /// <param name="value">The string value of the instance.</param>
 20        public KeyType(string value)
 21        {
 71622            _value = value ?? throw new ArgumentNullException(nameof(value));
 71623        }
 24
 25        /// <summary>
 26        /// An Elliptic Curve Cryptographic (ECC) algorithm.
 27        /// </summary>
 58628        public static KeyType Ec { get; } = new KeyType("EC");
 29
 30        /// <summary>
 31        /// An Elliptic Curve Cryptographic (ECC) algorithm backed by HSM.
 32        /// </summary>
 11233        public static KeyType EcHsm { get; } = new KeyType("EC-HSM");
 34
 35        /// <summary>
 36        /// An RSA cryptographic algorithm.
 37        /// </summary>
 73438        public static KeyType Rsa { get; } = new KeyType("RSA");
 39
 40        /// <summary>
 41        /// An RSA cryptographic algorithm backed by HSM.
 42        /// </summary>
 14443        public static KeyType RsaHsm { get; } = new KeyType("RSA-HSM");
 44
 45        /// <summary>
 46        /// An AES cryptographic algorithm.
 47        /// </summary>
 15648        public static KeyType Oct { get; } = new KeyType("oct");
 49
 50        /// <summary>
 51        /// Determines if two <see cref="KeyType"/> values are the same.
 52        /// </summary>
 53        /// <param name="left">The first <see cref="KeyType"/> to compare.</param>
 54        /// <param name="right">The second <see cref="KeyType"/> to compare.</param>
 55        /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are the same; otherwise, false.</retur
 93856        public static bool operator ==(KeyType left, KeyType right) => left.Equals(right);
 57
 58        /// <summary>
 59        /// Determines if two <see cref="KeyType"/> values are different.
 60        /// </summary>
 61        /// <param name="left">The first <see cref="KeyType"/> to compare.</param>
 62        /// <param name="right">The second <see cref="KeyType"/> to compare.</param>
 63        /// <returns>True if <paramref name="left"/> and <paramref name="right"/> are different; otherwise, false.</retu
 62664        public static bool operator !=(KeyType left, KeyType right) => !left.Equals(right);
 65
 66        /// <summary>
 67        /// Converts a string to a <see cref="KeyType"/>.
 68        /// </summary>
 69        /// <param name="value">The string value to convert.</param>
 70470        public static implicit operator KeyType(string value) => new KeyType(value);
 71
 72        /// <inheritdoc/>
 73        [EditorBrowsable(EditorBrowsableState.Never)]
 074        public override bool Equals(object obj) => obj is KeyType other && Equals(other);
 75
 76        /// <inheritdoc/>
 189277        public bool Equals(KeyType 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/>
 40284        public override string ToString() => _value;
 85    }
 86}