< Summary

Class:Microsoft.Azure.Batch.Auth.BatchTokenCredentials
Assembly:Microsoft.Azure.Batch
File(s):C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\Auth\BatchTokenCredentials.cs
Covered lines:0
Uncovered lines:18
Coverable lines:18
Total lines:59
Line coverage:0% (0 of 18)
Covered branches:0
Total branches:8
Branch coverage:0% (0 of 8)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
get_TokenProvider()-0%100%
.ctor(...)-0%0%
.ctor(...)-0%0%

File(s)

C:\Git\azure-sdk-for-net\sdk\batch\Microsoft.Azure.Batch\src\Auth\BatchTokenCredentials.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License. See License.txt in the project root for license information.
 3
 4namespace Microsoft.Azure.Batch.Auth
 5{
 6    using System;
 7    using System.Threading.Tasks;
 8
 9    /// <summary>
 10    /// Azure Active Directory token credentials for an Azure Batch account.
 11    /// </summary>
 12    public class BatchTokenCredentials : BatchCredentials
 13    {
 14        /// <summary>
 15        /// Gets a function which returns an authentication token.
 16        /// </summary>
 017        public Func<Task<string>> TokenProvider { get; }
 18
 19        /// <summary>
 20        /// Initializes a new instance of the <see cref="BatchTokenCredentials"/> class with the specified Batch service
 21        /// </summary>
 22        /// <param name="baseUrl">The Batch service endpoint.</param>
 23        /// <param name="token">An authentication token provided by Azure Active Directory.</param>
 024        public BatchTokenCredentials(string baseUrl, string token)
 25        {
 026            if (string.IsNullOrEmpty(baseUrl))
 27            {
 028                throw new ArgumentNullException(nameof(baseUrl));
 29            }
 030            if (string.IsNullOrEmpty(token))
 31            {
 032                throw new ArgumentNullException(nameof(token));
 33            }
 34
 035            this.BaseUrl = baseUrl;
 036            var tokenTask = Task.FromResult(token);
 037            TokenProvider = () => tokenTask;
 038        }
 39
 40        /// <summary>
 41        /// Initializes a new instance of the <see cref="BatchTokenCredentials" /> class with the specified Batch servic
 42        /// </summary>
 43        /// <param name="baseUrl">The Batch service endpoint.</param>
 44        /// <param name="tokenProvider">A function which returns an authentication token.</param>
 045        public BatchTokenCredentials(string baseUrl, Func<Task<string>> tokenProvider)
 46        {
 047            if (string.IsNullOrEmpty(baseUrl))
 48            {
 049                throw new ArgumentNullException(nameof(baseUrl));
 50            }
 051            if (tokenProvider == null)
 52            {
 053                throw new ArgumentNullException(nameof(tokenProvider));
 54            }
 055            this.BaseUrl = baseUrl;
 056            this.TokenProvider = tokenProvider;
 057        }
 58    }
 59}