< Summary

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

Metrics

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

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
 017        public Uri VaultUri { get; set; }
 18
 019        public string Name { get; set; }
 20
 021        public string Collection { get; set; }
 22
 023        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]
 038            if (id.Segments.Length != 3 && id.Segments.Length != 4)
 039                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Invalid ObjectIdentifier: {0}. 
 40
 041            KeyVaultIdentifier identifier = new KeyVaultIdentifier
 042            {
 043
 044                Id = id,
 045                VaultUri = new Uri($"{id.Scheme}://{id.Authority}"),
 046                Collection = id.Segments[1].Trim('/'),
 047                Name = id.Segments[2].Trim('/'),
 048                Version = (id.Segments.Length == 4) ? id.Segments[3].TrimEnd('/') : null
 049            };
 50
 051            return identifier;
 52        }
 53    }
 54}