< Summary

Class:Azure.Security.KeyVault.Certificates.CertificateModelFactory
Assembly:Azure.Security.KeyVault.Certificates
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Certificates\src\CertificateModelFactory.cs
Covered lines:0
Uncovered lines:89
Coverable lines:89
Total lines:284
Line coverage:0% (0 of 89)
Covered branches:0
Total branches:0

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
IssuerProperties(...)-0%100%
CertificateIssuer(...)-0%100%
CertificateOperationError(...)-0%100%
CertificateOperationProperties(...)-0%100%
CertificatePolicy(...)-0%100%
CertificateProperties(...)-0%100%
CertificateProperties(...)-0%100%
DeletedCertificate(...)-0%100%
KeyVaultCertificate(...)-0%100%
KeyVaultCertificateWithPolicy(...)-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Certificates\src\CertificateModelFactory.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    /// Model factory that enables mocking for the Key Vault Certificates library.
 11    /// </summary>
 12    public static class CertificateModelFactory
 13    {
 14        /// <summary>
 15        /// Initializes a new instance of the <see cref="Certificates.IssuerProperties"/> for mocking purposes.
 16        /// </summary>
 17        /// <param name="id">Sets the <see cref="Certificates.IssuerProperties.Id"/> property.</param>
 18        /// <param name="name">Sets the <see cref="Certificates.IssuerProperties.Name"/> property.</param>
 19        /// <returns>A new instance of the <see cref="Certificates.IssuerProperties"/> for mocking purposes.</returns>
 20        public static IssuerProperties IssuerProperties(
 21            Uri id = default,
 022            string name = default) => new IssuerProperties
 023            {
 024                Id = id,
 025                Name = name,
 026            };
 27
 28        /// <summary>
 29        /// Initializes a new instance of the <see cref="Certificates.CertificateIssuer"/> for mocking purposes.
 30        /// </summary>
 31        /// <param name="properties">Sets the <see cref="Certificates.CertificateIssuer.Id"/>, <see cref="Certificates.C
 32        /// <param name="createdOn">Sets the <see cref="Certificates.CertificateIssuer.CreatedOn"/> property.</param>
 33        /// <param name="updatedOn">Sets the <see cref="Certificates.CertificateIssuer.UpdatedOn"/> property.</param>
 34        /// <returns>A new instance of the <see cref="Certificates.CertificateIssuer"/> for mocking purposes.</returns>
 35        public static CertificateIssuer CertificateIssuer(
 36            IssuerProperties properties,
 37            DateTimeOffset? createdOn = default,
 038            DateTimeOffset? updatedOn = default) => new CertificateIssuer(properties)
 039            {
 040                CreatedOn = createdOn,
 041                UpdatedOn = updatedOn,
 042            };
 43
 44        // TODO: How should we support CertificateOperation?
 45
 46        /// <summary>
 47        /// Initializes a new instance of the <see cref="Certificates.CertificateOperationError"/> for mocking purposes.
 48        /// </summary>
 49        /// <param name="code">Sets the <see cref="Certificates.CertificateOperationError.Code"/> property.</param>
 50        /// <param name="message">Sets the <see cref="Certificates.CertificateOperationError.Message"/> property.</param
 51        /// <param name="innerError">Sets the <see cref="Certificates.CertificateOperationError.InnerError"/> property.<
 52        /// <returns>A new instance of the <see cref="Certificates.CertificateOperationError"/> for mocking purposes.</r
 53        public static CertificateOperationError CertificateOperationError(
 54            string code = default,
 55            string message = default,
 056            CertificateOperationError innerError = default) => new CertificateOperationError
 057            {
 058                Code = code,
 059                Message = message,
 060                InnerError = innerError,
 061            };
 62
 63        /// <summary>
 64        /// Initializes a new instance of the <see cref="Certificates.CertificateOperationProperties"/> for mocking purp
 65        /// </summary>
 66        /// <param name="id">Sets the <see cref="Certificates.CertificateOperationProperties.Id"/> property.</param>
 67        /// <param name="name">Sets the <see cref="Certificates.CertificateOperationProperties.Name"/> property.</param>
 68        /// <param name="vaultUri">Sets the <see cref="Certificates.CertificateOperationProperties.VaultUri"/> property.
 69        /// <param name="issuerName">Sets the <see cref="Certificates.CertificateOperationProperties.IssuerName"/> prope
 70        /// <param name="certificateType">Sets the <see cref="Certificates.CertificateOperationProperties.CertificateTyp
 71        /// <param name="certificateTransparency">Sets the <see cref="Certificates.CertificateOperationProperties.Certif
 72        /// <param name="csr">Sets the <see cref="Certificates.CertificateOperationProperties.Csr"/> property.</param>
 73        /// <param name="cancellationRequested">Sets the <see cref="Certificates.CertificateOperationProperties.Cancella
 74        /// <param name="requestId">Sets the <see cref="Certificates.CertificateOperationProperties.RequestId"/> propert
 75        /// <param name="status">Sets the <see cref="Certificates.CertificateOperationProperties.Status"/> property.</pa
 76        /// <param name="statusDetails">Sets the <see cref="Certificates.CertificateOperationProperties.StatusDetails"/>
 77        /// <param name="target">Sets the <see cref="Certificates.CertificateOperationProperties.Target"/> property.</pa
 78        /// <param name="error">Sets the <see cref="Certificates.CertificateOperationProperties.Error"/> property.</para
 79        /// <returns>A new instance of the <see cref="Certificates.CertificateOperationProperties"/> for mocking purpose
 80        public static CertificateOperationProperties CertificateOperationProperties(
 81            Uri id = default,
 82            string name = default,
 83            Uri vaultUri = default,
 84            string issuerName = default,
 85            string certificateType = default,
 86            bool? certificateTransparency = default,
 87            byte[] csr = default,
 88            bool cancellationRequested = default,
 89            string requestId = default,
 90            string status = default,
 91            string statusDetails = default,
 92            string target = default,
 093            CertificateOperationError error = default) => new CertificateOperationProperties
 094            {
 095                Id = id,
 096                Name = name,
 097                VaultUri = vaultUri,
 098                IssuerName = issuerName,
 099                CertificateType = certificateType,
 0100                CertificateTransparency = certificateTransparency,
 0101                Csr = csr,
 0102                CancellationRequested = cancellationRequested,
 0103                RequestId = requestId,
 0104                Status = status,
 0105                StatusDetails = statusDetails,
 0106                Target = target,
 0107                Error = error,
 0108            };
 109
 110        /// <summary>
 111        /// Initializes a new instance of the <see cref="Certificates.CertificatePolicy"/> for mocking purposes.
 112        /// </summary>
 113        /// <param name="subject">Sets the <see cref="Certificates.CertificatePolicy.Subject"/> property.</param>
 114        /// <param name="subjectAlternativeNames">Sets the <see cref="Certificates.CertificatePolicy.SubjectAlternativeN
 115        /// <param name="issuerName">Sets the <see cref="Certificates.CertificatePolicy.IssuerName"/> property.</param>
 116        /// <param name="createdOn">Sets the <see cref="Certificates.CertificatePolicy.CreatedOn"/> property.</param>
 117        /// <param name="updatedOn">Sets the <see cref="Certificates.CertificatePolicy.UpdatedOn"/> property.</param>
 118        /// <returns>A new instance of the <see cref="Certificates.CertificatePolicy"/> for mocking purposes.</returns>
 119        public static CertificatePolicy CertificatePolicy(
 120            string subject = default,
 121            SubjectAlternativeNames subjectAlternativeNames = default,
 122            string issuerName = default,
 123            DateTimeOffset? createdOn = default,
 0124            DateTimeOffset? updatedOn = default) => new CertificatePolicy
 0125            {
 0126                Subject = subject,
 0127                SubjectAlternativeNames = subjectAlternativeNames,
 0128                IssuerName = issuerName,
 0129                CreatedOn = createdOn,
 0130                UpdatedOn = updatedOn,
 0131            };
 132
 133        /// <summary>
 134        /// Initializes a new instance of the <see cref="Certificates.CertificateProperties"/> for mocking purposes.
 135        /// </summary>
 136        /// <param name="id">Sets the <see cref="Certificates.CertificateProperties.Id"/> property.</param>
 137        /// <param name="name">Sets the <see cref="Certificates.CertificateProperties.Name"/> property.</param>
 138        /// <param name="vaultUri">Sets the <see cref="Certificates.CertificateProperties.VaultUri"/> property.</param>
 139        /// <param name="version">Sets the <see cref="Certificates.CertificateProperties.Version"/> property.</param>
 140        /// <param name="x509thumbprint">Sets the <see cref="Certificates.CertificateProperties.X509Thumbprint"/> proper
 141        /// <param name="notBefore">Sets the <see cref="Certificates.CertificateProperties.NotBefore"/> property.</param
 142        /// <param name="expiresOn">Sets the <see cref="Certificates.CertificateProperties.ExpiresOn"/> property.</param
 143        /// <param name="createdOn">Sets the <see cref="Certificates.CertificateProperties.CreatedOn"/> property.</param
 144        /// <param name="updatedOn">Sets the <see cref="Certificates.CertificateProperties.UpdatedOn"/> property.</param
 145        /// <param name="recoveryLevel">Sets the <see cref="Certificates.CertificateProperties.RecoveryLevel"/> property
 146        /// <returns>A new instance of the <see cref="Certificates.CertificateProperties"/> for mocking purposes.</retur
 147        [EditorBrowsable(EditorBrowsableState.Never)]
 148        public static CertificateProperties CertificateProperties(
 149            Uri id,
 150            string name,
 151            Uri vaultUri,
 152            string version,
 153            byte[] x509thumbprint,
 154            DateTimeOffset? notBefore,
 155            DateTimeOffset? expiresOn,
 156            DateTimeOffset? createdOn,
 157            DateTimeOffset? updatedOn,
 0158            string recoveryLevel) => CertificateProperties(
 0159                id,
 0160                name,
 0161                vaultUri,
 0162                version,
 0163                x509thumbprint,
 0164                notBefore,
 0165                expiresOn,
 0166                createdOn,
 0167                updatedOn,
 0168                recoveryLevel,
 0169                default);
 170
 171        /// <summary>
 172        /// Initializes a new instance of the <see cref="Certificates.CertificateProperties"/> for mocking purposes.
 173        /// </summary>
 174        /// <param name="id">Sets the <see cref="Certificates.CertificateProperties.Id"/> property.</param>
 175        /// <param name="name">Sets the <see cref="Certificates.CertificateProperties.Name"/> property.</param>
 176        /// <param name="vaultUri">Sets the <see cref="Certificates.CertificateProperties.VaultUri"/> property.</param>
 177        /// <param name="version">Sets the <see cref="Certificates.CertificateProperties.Version"/> property.</param>
 178        /// <param name="x509thumbprint">Sets the <see cref="Certificates.CertificateProperties.X509Thumbprint"/> proper
 179        /// <param name="notBefore">Sets the <see cref="Certificates.CertificateProperties.NotBefore"/> property.</param
 180        /// <param name="expiresOn">Sets the <see cref="Certificates.CertificateProperties.ExpiresOn"/> property.</param
 181        /// <param name="createdOn">Sets the <see cref="Certificates.CertificateProperties.CreatedOn"/> property.</param
 182        /// <param name="updatedOn">Sets the <see cref="Certificates.CertificateProperties.UpdatedOn"/> property.</param
 183        /// <param name="recoveryLevel">Sets the <see cref="Certificates.CertificateProperties.RecoveryLevel"/> property
 184        /// <param name="recoverableDays">Sets the <see cref="Certificates.CertificateProperties.RecoverableDays"/> prop
 185        /// <returns>A new instance of the <see cref="Certificates.CertificateProperties"/> for mocking purposes.</retur
 186        public static CertificateProperties CertificateProperties(
 187            Uri id = default,
 188            string name = default,
 189            Uri vaultUri = default,
 190            string version = default,
 191            byte[] x509thumbprint = default,
 192            DateTimeOffset? notBefore = default,
 193            DateTimeOffset? expiresOn = default,
 194            DateTimeOffset? createdOn = default,
 195            DateTimeOffset? updatedOn = default,
 196            string recoveryLevel = default,
 0197            int? recoverableDays = default) => new CertificateProperties
 0198            {
 0199                Id = id,
 0200                Name = name,
 0201                VaultUri = vaultUri,
 0202                Version = version,
 0203                X509Thumbprint = x509thumbprint,
 0204                NotBefore = notBefore,
 0205                ExpiresOn = expiresOn,
 0206                CreatedOn = createdOn,
 0207                UpdatedOn = updatedOn,
 0208                RecoveryLevel = recoveryLevel,
 0209                RecoverableDays = recoverableDays,
 0210            };
 211
 212        /// <summary>
 213        /// Initializes a new instance of the <see cref="Certificates.DeletedCertificate"/> for mocking purposes.
 214        /// </summary>
 215        /// <param name="properties">Sets the <see cref="Certificates.KeyVaultCertificate.Properties"/> property.</param
 216        /// <param name="keyId">Sets the <see cref="Certificates.KeyVaultCertificate.KeyId"/> property.</param>
 217        /// <param name="secretId">Sets the <see cref="Certificates.KeyVaultCertificate.SecretId"/> property.</param>
 218        /// <param name="cer">Sets the <see cref="Certificates.KeyVaultCertificate.Cer"/> property.</param>
 219        /// <param name="policy">Sets the <see cref="Certificates.KeyVaultCertificateWithPolicy.Policy"/> property.</par
 220        /// <param name="recoveryId">Sets the <see cref="Certificates.DeletedCertificate.RecoveryId"/> property.</param>
 221        /// <param name="deletedOn">Sets the <see cref="Certificates.DeletedCertificate.DeletedOn"/> property.</param>
 222        /// <param name="scheduledPurgeDate">Sets the <see cref="Certificates.DeletedCertificate.ScheduledPurgeDate"/> p
 223        /// <returns>A new instance of the <see cref="Certificates.DeletedCertificate"/> for mocking purposes.</returns>
 224        public static DeletedCertificate DeletedCertificate(
 225            CertificateProperties properties,
 226            Uri keyId = default,
 227            Uri secretId = default,
 228            byte[] cer = default,
 229            CertificatePolicy policy = default,
 230            Uri recoveryId = default,
 231            DateTimeOffset? deletedOn = default,
 0232            DateTimeOffset? scheduledPurgeDate = default) => new DeletedCertificate(properties)
 0233            {
 0234                KeyId = keyId,
 0235                SecretId = secretId,
 0236                Cer = cer,
 0237                Policy = policy,
 0238                RecoveryId = recoveryId,
 0239                DeletedOn = deletedOn,
 0240                ScheduledPurgeDate = scheduledPurgeDate,
 0241            };
 242
 243        /// <summary>
 244        /// Initializes a new instance of the <see cref="Certificates.KeyVaultCertificate"/> for mocking purposes.
 245        /// </summary>
 246        /// <param name="properties">Sets the <see cref="Certificates.KeyVaultCertificate.Properties"/> property.</param
 247        /// <param name="keyId">Sets the <see cref="Certificates.KeyVaultCertificate.KeyId"/> property.</param>
 248        /// <param name="secretId">Sets the <see cref="Certificates.KeyVaultCertificate.SecretId"/> property.</param>
 249        /// <param name="cer">Sets the <see cref="Certificates.KeyVaultCertificate.Cer"/> property.</param>
 250        /// <returns>A new instance of the <see cref="Certificates.KeyVaultCertificate"/> for mocking purposes.</returns
 251        public static KeyVaultCertificate KeyVaultCertificate(
 252            CertificateProperties properties,
 253            Uri keyId = default,
 254            Uri secretId = default,
 0255            byte[] cer = default) => new KeyVaultCertificate(properties)
 0256            {
 0257                KeyId = keyId,
 0258                SecretId = secretId,
 0259                Cer = cer,
 0260            };
 261
 262        /// <summary>
 263        /// Initializes a new instance of the <see cref="Certificates.KeyVaultCertificateWithPolicy"/> for mocking purpo
 264        /// </summary>
 265        /// <param name="properties">Sets the <see cref="Certificates.KeyVaultCertificate.Properties"/> property.</param
 266        /// <param name="keyId">Sets the <see cref="Certificates.KeyVaultCertificate.KeyId"/> property.</param>
 267        /// <param name="secretId">Sets the <see cref="Certificates.KeyVaultCertificate.SecretId"/> property.</param>
 268        /// <param name="cer">Sets the <see cref="Certificates.KeyVaultCertificate.Cer"/> property.</param>
 269        /// <param name="policy">Sets the <see cref="Certificates.KeyVaultCertificateWithPolicy.Policy"/> property.</par
 270        /// <returns>A new instance of the <see cref="Certificates.KeyVaultCertificateWithPolicy"/> for mocking purposes
 271        public static KeyVaultCertificateWithPolicy KeyVaultCertificateWithPolicy(
 272            CertificateProperties properties,
 273            Uri keyId = default,
 274            Uri secretId = default,
 275            byte[] cer = default,
 0276            CertificatePolicy policy = default) => new KeyVaultCertificateWithPolicy(properties)
 0277            {
 0278                KeyId = keyId,
 0279                SecretId = secretId,
 0280                Cer = cer,
 0281                Policy = policy,
 0282            };
 283    }
 284}