Beispiel #1
0
        private async Task <AzureAuthenticationManager> CreateAccountManager(AccountTokenWrapper currentAccount,
                                                                             IEnumerable <IAzureUserAccountSubscriptionContext> subscriptions, bool shouldFail = false)
        {
            AzureAuthenticationManager azureAuthenticationManager = new AzureAuthenticationManager();

            azureAuthenticationManager.SetServiceProvider(serviceProvider);
            if (currentAccount != null)
            {
                await azureAuthenticationManager.SetCurrentAccountAsync(currentAccount);
            }

            if (!shouldFail)
            {
                resourceManagerMock.Setup(x => x.GetSubscriptionContextsAsync(It.IsAny <IAzureUserAccount>())).Returns(Task.FromResult(subscriptions));
            }
            else
            {
                resourceManagerMock.Setup(x => x.GetSubscriptionContextsAsync(It.IsAny <IAzureUserAccount>())).Throws(new Exception());
            }

            return(azureAuthenticationManager);
        }