< Summary

Class:Azure.Security.KeyVault.Secrets.ObjectId
Assembly:Azure.Security.KeyVault.Secrets
File(s):C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Secrets\src\ObjectId.cs
Covered lines:12
Uncovered lines:2
Coverable lines:14
Total lines:37
Line coverage:85.7% (12 of 14)
Covered branches:6
Total branches:8
Branch coverage:75% (6 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_Id()-100%100%
get_VaultUri()-100%100%
get_Name()-100%100%
get_Version()-100%100%
ParseId(...)-100%100%
ParseId(...)-77.78%75%

File(s)

C:\Git\azure-sdk-for-net\sdk\keyvault\Azure.Security.KeyVault.Secrets\src\ObjectId.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.Secrets
 8{
 9    internal struct ObjectId
 10    {
 3355611        public Uri Id { get; set; }
 12
 154413        public Uri VaultUri { get; set; }
 14
 4610015        public string Name { get; set; }
 16
 159617        public string Version { get; set; }
 18
 154419        public void ParseId(string collection, string id) => ParseId(collection, new Uri(id, UriKind.Absolute));
 20
 21        public void ParseId(string collection, Uri id)
 22        {
 154423            Id = id;
 24
 25            // We expect an identifier with either 3 or 4 segments: host + collection + name [+ version]
 154426            if (Id.Segments.Length != 3 && Id.Segments.Length != 4)
 027                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Invalid ObjectIdentifier: {0}. 
 28
 154429            if (!string.Equals(Id.Segments[1], collection + "/", StringComparison.OrdinalIgnoreCase))
 030                throw new ArgumentException(string.Format(CultureInfo.InvariantCulture, "Invalid ObjectIdentifier: {0}. 
 31
 154432            VaultUri = new Uri($"{Id.Scheme}://{Id.Authority}");
 154433            Name = Id.Segments[2].Trim('/');
 154434            Version = (Id.Segments.Length == 4) ? Id.Segments[3].TrimEnd('/') : null;
 154435        }
 36    }
 37}