< Summary

Class:Azure.Core.AccessToken
Assembly:Azure.Core
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\AccessToken.cs
Covered lines:5
Uncovered lines:4
Coverable lines:9
Total lines:51
Line coverage:55.5% (5 of 9)
Covered branches:0
Total branches:4
Branch coverage:0% (0 of 4)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
get_Token()-100%100%
get_ExpiresOn()-100%100%
Equals(...)-0%0%
GetHashCode()-0%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\core\Azure.Core\src\AccessToken.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5
 6namespace Azure.Core
 7{
 8    /// <summary>
 9    /// Represents an Azure service bearer access token with expiry information.
 10    /// </summary>
 11    public struct AccessToken
 12    {
 13        /// <summary>
 14        /// Creates a new instance of <see cref="AccessToken"/> using the provided <paramref name="accessToken"/> and <p
 15        /// </summary>
 16        /// <param name="accessToken">The bearer access token value.</param>
 17        /// <param name="expiresOn">The bearer access token expiry date.</param>
 18        public AccessToken(string accessToken, DateTimeOffset expiresOn)
 19        {
 6820            Token = accessToken;
 6821            ExpiresOn = expiresOn;
 6822        }
 23
 24        /// <summary>
 25        /// Get the access token value.
 26        /// </summary>
 6827        public string Token { get; }
 28
 29        /// <summary>
 30        /// Gets the time when the provided token expires.
 31        /// </summary>
 13632        public DateTimeOffset ExpiresOn { get; }
 33
 34        /// <inheritdoc />
 35        public override bool Equals(object? obj)
 36        {
 037            if (obj is AccessToken accessToken)
 38            {
 039                return accessToken.ExpiresOn == ExpiresOn && accessToken.Token == Token;
 40            }
 41
 042            return false;
 43        }
 44
 45        /// <inheritdoc />
 46        public override int GetHashCode()
 47        {
 048            return Token.GetHashCode() ^ ExpiresOn.GetHashCode();
 49        }
 50    }
 51}