< Summary

Class:Azure.Security.KeyVault.Keys.DeletedKey
Assembly:Azure.Security.KeyVault.Keys
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Keys\src\DeletedKey.cs
Covered lines:16
Uncovered lines:1
Coverable lines:17
Total lines:69
Line coverage:94.1% (16 of 17)
Covered branches:7
Total branches:10
Branch coverage:70% (7 of 10)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
.ctor(...)-100%100%
get_RecoveryId()-100%50%
set_RecoveryId(...)-0%0%
get_DeletedOn()-100%100%
get_ScheduledPurgeDate()-100%100%
ReadProperty(...)-100%100%

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Text.Json;
 6
 7namespace Azure.Security.KeyVault.Keys
 8{
 9    /// <summary>
 10    /// Represents a Key Vault key that has been deleted, allowing it to be recovered, if needed.
 11    /// </summary>
 12    public class DeletedKey : KeyVaultKey
 13    {
 14        private const string RecoveryIdPropertyName = "recoveryId";
 15        private const string DeletedOnPropertyName = "deletedDate";
 16        private const string ScheduledPurgeDatePropertyName = "scheduledPurgeDate";
 17
 18        private string _recoveryId;
 19
 1620        internal DeletedKey(KeyProperties properties = null) : base(properties)
 21        {
 1622        }
 23
 5624        internal DeletedKey(string name) : base(name)
 25        {
 5626        }
 27
 28        /// <summary>
 29        /// Gets a <see cref="Uri"/> of the deleted key that can be used to recover it.
 30        /// </summary>
 31        public Uri RecoveryId
 32        {
 6833            get => _recoveryId is null ? null : new Uri(_recoveryId);
 034            internal set => _recoveryId = value?.ToString();
 35        }
 36
 37        /// <summary>
 38        /// Gets a <see cref="DateTimeOffset"/> indicating when the key was deleted.
 39        /// </summary>
 9640        public DateTimeOffset? DeletedOn { get; internal set; }
 41
 42        /// <summary>
 43        /// Gets a <see cref="DateTimeOffset"/> for when the deleted key will be purged.
 44        /// </summary>
 9645        public DateTimeOffset? ScheduledPurgeDate { get; internal set; }
 46
 47        internal override void ReadProperty(JsonProperty prop)
 48        {
 36049            switch (prop.Name)
 50            {
 51                case RecoveryIdPropertyName:
 7252                    _recoveryId = prop.Value.GetString();
 7253                    break;
 54
 55                case DeletedOnPropertyName:
 7256                    DeletedOn = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64());
 7257                    break;
 58
 59                case ScheduledPurgeDatePropertyName:
 7260                    ScheduledPurgeDate = DateTimeOffset.FromUnixTimeSeconds(prop.Value.GetInt64());
 7261                    break;
 62
 63                default:
 14464                    base.ReadProperty(prop);
 65                    break;
 66            }
 14467        }
 68    }
 69}