SetGetAsyncResponses() публичный статический Метод

public static SetGetAsyncResponses ( Queue responses ) : void
responses Queue
Результат void
        public void SubscriptionIdNotExist()
        {
            var tenants = new List <string> {
                DefaultTenant.ToString()
            };
            var firstList = new List <string> {
                Guid.NewGuid().ToString()
            };
            var client = SetupTestEnvironment(tenants, firstList);

            ((MockTokenAuthenticationFactory)AzureSession.Instance.AuthenticationFactory).TokenProvider = (account, environment, tenant) =>
                                                                                                          new MockAccessToken
            {
                UserId      = "*****@*****.**",
                LoginType   = LoginType.OrgId,
                AccessToken = "bbb",
                TenantId    = DefaultTenant.ToString()
            };

            var getAsyncResponses = new Queue <Func <AzureOperationResponse <Subscription> > >();

            getAsyncResponses.Enqueue(() =>
            {
                throw new CloudException("InvalidAuthenticationTokenTenant: The access token is from the wrong issuer");
            });
            MockSubscriptionClientFactory.SetGetAsyncResponses(getAsyncResponses);

            Assert.Throws <PSInvalidOperationException>(() => client.Login(
                                                            Context.Account,
                                                            Context.Environment,
                                                            null,
                                                            DefaultSubscription.ToString(),
                                                            null,
                                                            null));
        }
Пример #2
0
        public void SubscriptionIdNotInFirstTenant()
        {
            var tenants = new List <string> {
                DefaultTenant.ToString(), Guid.NewGuid().ToString()
            };
            var subscriptionInSecondTenant = Guid.NewGuid().ToString();
            var firstList = new List <string> {
                DefaultSubscription.ToString()
            };
            var secondList = new List <string> {
                Guid.NewGuid().ToString(), subscriptionInSecondTenant
            };
            var client = SetupTestEnvironment(tenants, firstList, secondList);

            ((MockTokenAuthenticationFactory)AzureSession.AuthenticationFactory).TokenProvider = (account, environment, tenant) =>
                                                                                                 new MockAccessToken
            {
                UserId      = "*****@*****.**",
                LoginType   = LoginType.OrgId,
                AccessToken = "bbb",
                TenantId    = DefaultTenant.ToString()
            };

            var getAsyncResponses = new Queue <Func <GetSubscriptionResult> >();

            getAsyncResponses.Enqueue(() =>
            {
                throw new CloudException("InvalidAuthenticationTokenTenant: The access token is from the wrong issuer");
            });
            MockSubscriptionClientFactory.SetGetAsyncResponses(getAsyncResponses);

            var azureRmProfile = client.Login(
                Context.Account,
                Context.Environment,
                null,
                subscriptionInSecondTenant,
                null,
                null);
        }