コード例 #1
0
        private static RMProfileClient SetupTestEnvironment(List <string> tenants, params List <string>[] subscriptionLists)
        {
            AzureSession.AuthenticationFactory = new MockTokenAuthenticationFactory(DefaultAccount,
                                                                                    Guid.NewGuid().ToString(), DefaultTenant.ToString());
            var subscriptionList = new Queue <List <string> >(subscriptionLists);
            var clientFactory    = new MockSubscriptionClientFactory(tenants, subscriptionList);
            var mock             = new MockClientFactory(new List <object>
            {
                clientFactory.GetSubscriptionClient()
            }, true);

            mock.MoqClients            = true;
            AzureSession.ClientFactory = mock;
            Context = new AzureContext(new AzureSubscription()
            {
                Account     = DefaultAccount,
                Environment = EnvironmentName.AzureCloud,
                Id          = DefaultSubscription,
                Name        = DefaultSubscriptionName
            },
                                       new AzureAccount()
            {
                Id = DefaultAccount, Type = AzureAccount.AccountType.User
            },
                                       AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud],
                                       new AzureTenant()
            {
                Domain = DefaultDomain, Id = DefaultTenant
            });
            var profile = new AzureRMProfile();

            profile.Context = Context;
            return(new RMProfileClient(profile));
        }
コード例 #2
0
 private static RMProfileClient SetupTestEnvironment(List<string> tenants, params List<string>[] subscriptionLists)
 {
     AzureSession.AuthenticationFactory = new MockTokenAuthenticationFactory(DefaultAccount,
         Guid.NewGuid().ToString(), DefaultTenant.ToString());
     var subscriptionList = new Queue<List<string>>(subscriptionLists);
     var clientFactory = new MockSubscriptionClientFactory(tenants, subscriptionList);
     var mock = new MockClientFactory(new List<object>
     {
         clientFactory.GetSubscriptionClient()
     }, true);
     mock.MoqClients = true;
     AzureSession.ClientFactory = mock;
     Context = new AzureContext(new AzureSubscription()
         {
             Account = DefaultAccount,
             Environment = EnvironmentName.AzureCloud,
             Id = DefaultSubscription,
             Name = DefaultSubscriptionName
         },
         new AzureAccount() { Id = DefaultAccount, Type = AzureAccount.AccountType.User },
         AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud],
         new AzureTenant() { Domain = DefaultDomain, Id = DefaultTenant });
     var profile = new AzureRMProfile();
     profile.Context = Context;
     return new RMProfileClient(profile);
 }