< Summary

Class:Azure.Security.KeyVault.KeyVaultIdentifier
Assembly:Azure.Security.KeyVault.Keys
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Shared\src\KeyVaultIdentifier.cs
Covered lines:15
Uncovered lines:6
Coverable lines:21
Total lines:54
Line coverage:71.4% (15 of 21)
Covered branches:5
Total branches:8
Branch coverage:62.5% (5 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_Id()-0%100%
get_VaultUri()-100%100%
get_Name()-100%100%
get_Collection()-100%100%
get_Version()-100%100%
Parse(...)-0%0%
Parse(...)-91.67%83.33%

File(s)

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

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Globalization;
 6
 7namespace Azure.Security.KeyVault
 8{
 9    internal struct KeyVaultIdentifier
 10    {
 11        public const string SecretsCollection = "secrets";
 12        public const string KeysCollection = "keys";
 13        public const string CertificatesCollection = "certificates";
 14
 015        public Uri Id { get; private set; }
 16
 3617        public Uri VaultUri { get; set; }
 18
 3619        public string Name { get; set; }
 20
 6021        public string Collection { get; set; }
 22
 3623        public string Version { get; set; }
 24
 25        public static KeyVaultIdentifier Parse(string collection, Uri id)
 26        {
 027            KeyVaultIdentifier identifier = Parse(id);
 28
 029            if (!string.Equals(identifier.Collection, collection + "/", StringComparison.OrdinalIgnoreCase))
 030                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Invalid ObjectIdentifier: {0}. 
 31
 032            return identifier;
 33        }
 34
 35        public static KeyVaultIdentifier Parse(Uri id)
 36        {
 37            // We expect an identifier with either 3 or 4 segments: host + collection + name [+ version]
 3238            if (id.Segments.Length != 3 && id.Segments.Length != 4)
 039                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Invalid ObjectIdentifier: {0}. 
 40
 3241            KeyVaultIdentifier identifier = new KeyVaultIdentifier
 3242            {
 3243
 3244                Id = id,
 3245                VaultUri = new Uri($"{id.Scheme}://{id.Authority}"),
 3246                Collection = id.Segments[1].Trim('/'),
 3247                Name = id.Segments[2].Trim('/'),
 3248                Version = (id.Segments.Length == 4) ? id.Segments[3].TrimEnd('/') : null
 3249            };
 50
 3251            return identifier;
 52        }
 53    }
 54}