< Summary

Class:Azure.Security.KeyVault.Keys.KeyModelFactory
Assembly:Azure.Security.KeyVault.Keys
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Keys\src\KeyModelFactory.cs
Covered lines:18
Uncovered lines:33
Coverable lines:51
Total lines:171
Line coverage:35.2% (18 of 51)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
JsonWebKey(...)-100%100%
KeyProperties(...)-0%100%
KeyProperties(...)-0%100%
KeyVaultKey(...)-0%100%
DeletedKey(...)-0%100%

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Collections.Generic;
 6using System.ComponentModel;
 7
 8namespace Azure.Security.KeyVault.Keys
 9{
 10    /// <summary>
 11    /// Model factory that enables mocking for the Key Vault Keys library.
 12    /// </summary>
 13    public static class KeyModelFactory
 14    {
 15        /// <summary>
 16        /// Initializes a new instance of the <see cref="Keys.JsonWebKey"/> for mocking purposes.
 17        /// </summary>
 18        /// <param name="keyType">Sets the <see cref="Keys.JsonWebKey.KeyType"/> property.</param>
 19        /// <param name="id">Sets the <see cref="Keys.JsonWebKey.Id"/> property.</param>
 20        /// <param name="keyOps">Sets the <see cref="Keys.JsonWebKey.KeyOps"/> property.</param>
 21        /// <param name="curveName">Sets the <see cref="Keys.JsonWebKey.CurveName"/> property.</param>
 22        /// <param name="d">Sets the <see cref="Keys.JsonWebKey.D"/> property.</param>
 23        /// <param name="dp">Sets the <see cref="Keys.JsonWebKey.DP"/> property.</param>
 24        /// <param name="dq">Sets the <see cref="Keys.JsonWebKey.DQ"/> property.</param>
 25        /// <param name="e">Sets the <see cref="Keys.JsonWebKey.E"/> property.</param>
 26        /// <param name="k">Sets the <see cref="Keys.JsonWebKey.K"/> property.</param>
 27        /// <param name="n">Sets the <see cref="Keys.JsonWebKey.N"/> property.</param>
 28        /// <param name="p">Sets the <see cref="Keys.JsonWebKey.P"/> property.</param>
 29        /// <param name="q">Sets the <see cref="Keys.JsonWebKey.Q"/> property.</param>
 30        /// <param name="qi">Sets the <see cref="Keys.JsonWebKey.QI"/> property.</param>
 31        /// <param name="t">Sets the <see cref="Keys.JsonWebKey.T"/> property.</param>
 32        /// <param name="x">Sets the <see cref="Keys.JsonWebKey.X"/> property.</param>
 33        /// <param name="y">Sets the <see cref="Keys.JsonWebKey.Y"/> property.</param>
 34        /// <returns>A new instance of the <see cref="Keys.JsonWebKey"/> for mocking purposes.</returns>
 35        public static JsonWebKey JsonWebKey(
 36            KeyType keyType,
 37            string id = default,
 38            IEnumerable<KeyOperation> keyOps = default,
 39            KeyCurveName? curveName = default,
 40            byte[] d = default,
 41            byte[] dp = default,
 42            byte[] dq = default,
 43            byte[] e = default,
 44            byte[] k = default,
 45            byte[] n = default,
 46            byte[] p = default,
 47            byte[] q = default,
 48            byte[] qi = default,
 49            byte[] t = default,
 50            byte[] x = default,
 51            byte[] y = default)
 52        {
 2053            return new JsonWebKey(keyOps)
 2054            {
 2055                KeyType = keyType,
 2056                Id = id,
 2057                CurveName = curveName,
 2058                D = d,
 2059                DP = dp,
 2060                DQ = dq,
 2061                E = e,
 2062                K = k,
 2063                N = n,
 2064                P = p,
 2065                Q = q,
 2066                QI = qi,
 2067                T = t,
 2068                X = x,
 2069                Y = y,
 2070            };
 71        }
 72
 73        /// <summary>
 74        /// Initializes a new instance of the <see cref="Keys.KeyProperties"/> for mocking purposes.
 75        /// </summary>
 76        /// <param name="id">Sets the <see cref="Keys.KeyProperties.Id"/> property.</param>
 77        /// <param name="vaultUri">Sets the <see cref="Keys.KeyProperties.VaultUri"/> property.</param>
 78        /// <param name="name">Sets the <see cref="Keys.KeyProperties.Name"/> property.</param>
 79        /// <param name="version">Sets the <see cref="Keys.KeyProperties.Version"/> property.</param>
 80        /// <param name="managed">Sets the <see cref="Keys.KeyProperties.Managed"/> property.</param>
 81        /// <param name="createdOn">Sets the <see cref="Keys.KeyProperties.CreatedOn"/> property.</param>
 82        /// <param name="updatedOn">Sets the <see cref="Keys.KeyProperties.UpdatedOn"/> property.</param>
 83        /// <param name="recoveryLevel">Sets the <see cref="Keys.KeyProperties.RecoveryLevel"/> property.</param>
 84        /// <returns>A new instance of the <see cref="Keys.KeyProperties"/> for mocking purposes.</returns>
 85        [EditorBrowsable(EditorBrowsableState.Never)]
 86        public static KeyProperties KeyProperties(
 87            Uri id,
 88            Uri vaultUri,
 89            string name,
 90            string version,
 91            bool managed,
 92            DateTimeOffset? createdOn,
 93            DateTimeOffset? updatedOn,
 094            string recoveryLevel) => KeyProperties(
 095                id,
 096                vaultUri,
 097                name,
 098                version,
 099                managed,
 0100                createdOn,
 0101                updatedOn,
 0102                recoveryLevel,
 0103                default);
 104
 105        /// <summary>
 106        /// Initializes a new instance of the <see cref="Keys.KeyProperties"/> for mocking purposes.
 107        /// </summary>
 108        /// <param name="id">Sets the <see cref="Keys.KeyProperties.Id"/> property.</param>
 109        /// <param name="vaultUri">Sets the <see cref="Keys.KeyProperties.VaultUri"/> property.</param>
 110        /// <param name="name">Sets the <see cref="Keys.KeyProperties.Name"/> property.</param>
 111        /// <param name="version">Sets the <see cref="Keys.KeyProperties.Version"/> property.</param>
 112        /// <param name="managed">Sets the <see cref="Keys.KeyProperties.Managed"/> property.</param>
 113        /// <param name="createdOn">Sets the <see cref="Keys.KeyProperties.CreatedOn"/> property.</param>
 114        /// <param name="updatedOn">Sets the <see cref="Keys.KeyProperties.UpdatedOn"/> property.</param>
 115        /// <param name="recoveryLevel">Sets the <see cref="Keys.KeyProperties.RecoveryLevel"/> property.</param>
 116        /// <param name="recoverableDays">Sets the <see cref="Keys.KeyProperties.RecoverableDays"/> property.</param>
 117        /// <returns>A new instance of the <see cref="Keys.KeyProperties"/> for mocking purposes.</returns>
 118        public static KeyProperties KeyProperties(
 119            Uri id = default,
 120            Uri vaultUri = default,
 121            string name = default,
 122            string version = default,
 123            bool managed = default,
 124            DateTimeOffset? createdOn = default,
 125            DateTimeOffset? updatedOn = default,
 126            string recoveryLevel = default,
 127            int? recoverableDays = default)
 128        {
 0129            return new KeyProperties
 0130            {
 0131                Id = id,
 0132                VaultUri = vaultUri,
 0133                Name = name,
 0134                Version = version,
 0135                Managed = managed,
 0136                CreatedOn = createdOn,
 0137                UpdatedOn = updatedOn,
 0138                RecoveryLevel = recoveryLevel,
 0139                RecoverableDays = recoverableDays,
 0140            };
 141        }
 142
 143        /// <summary>
 144        /// Initializes a new instance of the <see cref="Keys.KeyVaultKey"/> for mocking purposes.
 145        /// </summary>
 146        /// <param name="properties">Sets the <see cref="Keys.KeyVaultKey.Properties"/> property, which provides the <se
 147        /// <param name="key">Sets the <see cref="Keys.KeyVaultKey.Key"/> property, which provides the <see cref="Keys.K
 148        /// <returns>A new instance of the <see cref="Keys.KeyVaultKey"/> for mocking purposes.</returns>
 0149        public static KeyVaultKey KeyVaultKey(KeyProperties properties, JsonWebKey key) => new KeyVaultKey(properties)
 0150        {
 0151            Key = key,
 0152        };
 153
 154        /// <summary>
 155        /// Initializes a new instance of the <see cref="Keys.DeletedKey"/> for mocking purposes.
 156        /// </summary>
 157        /// <param name="properties">Sets the <see cref="Keys.KeyVaultKey.Properties"/> property, which provides the <se
 158        /// <param name="key">Sets the <see cref="Keys.KeyVaultKey.Key"/> property, which provides the <see cref="Keys.K
 159        /// <param name="recoveryId">Sets the <see cref="Keys.DeletedKey.RecoveryId"/> property.</param>
 160        /// <param name="deletedOn">Sets the <see cref="Keys.DeletedKey.DeletedOn"/> property.</param>
 161        /// <param name="scheduledPurgeDate">Sets the <see cref="Keys.DeletedKey.ScheduledPurgeDate"/> property.</param>
 162        /// <returns>A new instance of the <see cref="Keys.DeletedKey"/> for mocking purposes.</returns>
 0163        public static DeletedKey DeletedKey(KeyProperties properties, JsonWebKey key, Uri recoveryId = default, DateTime
 0164        {
 0165            Key = key,
 0166            RecoveryId = recoveryId,
 0167            DeletedOn = deletedOn,
 0168            ScheduledPurgeDate = scheduledPurgeDate,
 0169        };
 170    }
 171}