< Summary

Information
Line coverage
100%
Covered lines: 2
Uncovered lines: 0
Coverable lines: 2
Total lines: 33
Line coverage: 100%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
GetDomain(...)100%11100%
GetName(...)100%11100%

File(s)

https://raw.githubusercontent.com/sandre58/MyNet/85372080fe102cd9ee155ceab49ae000e7f66103/src/MyNet.Utilities/Authentication/Extensions/IdentityExtensions.cs

#LineLine coverage
 1// -----------------------------------------------------------------------
 2// <copyright file="IdentityExtensions.cs" company="Stéphane ANDRE">
 3// Copyright (c) Stéphane ANDRE. All rights reserved.
 4// </copyright>
 5// -----------------------------------------------------------------------
 6
 7using System.Security.Principal;
 8using MyNet.Utilities.Authentication;
 9
 10#pragma warning disable IDE0130 // Namespace does not match folder structure
 11namespace MyNet.Utilities;
 12#pragma warning restore IDE0130 // Namespace does not match folder structure
 13
 14/// <summary>
 15/// Provides convenience extension methods for reading name components from an <see cref="IIdentity"/>.
 16/// </summary>
 17public static class IdentityExtensions
 18{
 19    extension(IIdentity identity)
 20    {
 21        /// <summary>
 22        /// Extracts the domain part from the identity name.
 23        /// Returns an empty string when the identity does not contain a domain.
 24        /// </summary>
 1925        public string GetDomain() => IdentityHelper.GetDomain(identity.Name);
 26
 27        /// <summary>
 28        /// Extracts the user name part from the identity name.
 29        /// </summary>
 1930        public string GetName() => IdentityHelper.GetName(identity.Name);
 31    }
 32}
 33