当前位置: 首页>>代码示例>>C#>>正文


C# ProfileClient.AddAccountAndLoadSubscriptions方法代码示例

本文整理汇总了C#中ProfileClient.AddAccountAndLoadSubscriptions方法的典型用法代码示例。如果您正苦于以下问题:C# ProfileClient.AddAccountAndLoadSubscriptions方法的具体用法?C# ProfileClient.AddAccountAndLoadSubscriptions怎么用?C# ProfileClient.AddAccountAndLoadSubscriptions使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProfileClient的用法示例。


在下文中一共展示了ProfileClient.AddAccountAndLoadSubscriptions方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: AddAzureAccountReturnsAccountWithAllSubscriptionsInCsmMode

        public void AddAzureAccountReturnsAccountWithAllSubscriptionsInCsmMode()
        {
            SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1 }.ToList());
            MockDataStore dataStore = new MockDataStore();
            dataStore.VirtualStore[oldProfileDataPath] = oldProfileData;
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();
            PowerShellUtilities.GetCurrentModeOverride = () => AzureModule.AzureResourceManager;

            var account = client.AddAccountAndLoadSubscriptions(new AzureAccount { Id = "test", Type = AzureAccount.AccountType.User }, AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud], null);

            Assert.Equal("test", account.Id);
            Assert.Equal(3, account.GetSubscriptions(client.Profile).Count);
            Assert.True(account.GetSubscriptions(client.Profile).Any(s => s.Id == new Guid(rdfeSubscription1.SubscriptionId)));
            Assert.True(account.GetSubscriptions(client.Profile).Any(s => s.Id == new Guid(rdfeSubscription2.SubscriptionId)));
            Assert.True(account.GetSubscriptions(client.Profile).Any(s => s.Id == new Guid(csmSubscription1.SubscriptionId)));
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:17,代码来源:ProfileClientTests.cs

示例2: AddAzureAccountIsCaseInsensitive

        public void AddAzureAccountIsCaseInsensitive()
        {
            SetMocks(new[] { rdfeSubscription1, guestRdfeSubscription }.ToList(),
                     new List<Microsoft.Azure.Subscriptions.Models.Subscription>(),
                     new[] { commonTenant, guestTenant }.ToList(),
                     (userAccount, environment, tenant) =>
                     {
                         var token = new MockAccessToken
                         {
                             UserId = tenant == commonTenant.TenantId ? userAccount.Id : "USERA",
                             AccessToken = "def",
                             LoginType = LoginType.OrgId
                         };
                         userAccount.Id = token.UserId;
                         return token;
                     });
            MemoryDataStore dataStore = new MemoryDataStore();
            dataStore.VirtualStore[oldProfileDataPath] = oldProfileData;
            AzureSession.DataStore = dataStore;
            currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            ProfileClient client = new ProfileClient(currentProfile);

            var account = client.AddAccountAndLoadSubscriptions(new AzureAccount { Id = "UserA", Type = AzureAccount.AccountType.User },
                AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud], null);

            var userA = client.GetAccount("UserA");
            var secondUserA = client.GetAccount("USERA");
            Assert.NotNull(userA);
            Assert.NotNull(secondUserA);
            Assert.Equal(userA.Id, secondUserA.Id);
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:31,代码来源:ProfileClientTests.cs

示例3: AddAzureAccountReturnsAccountWithAllSubscriptionsInCsmMode

        public void AddAzureAccountReturnsAccountWithAllSubscriptionsInCsmMode()
        {
            SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1 }.ToList());
            MemoryDataStore dataStore = new MemoryDataStore();
            dataStore.VirtualStore[oldProfileDataPath] = oldProfileData;
            AzureSession.DataStore = dataStore;
            currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            ProfileClient client = new ProfileClient(currentProfile);

            var account = client.AddAccountAndLoadSubscriptions(
                    new AzureAccount
                    {
                        Id = "test",
                        Type = AzureAccount.AccountType.User
                    },
                    AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud],
                    null);

            Assert.Equal("test", account.Id);
            Assert.Equal(2, account.GetSubscriptions(client.Profile).Count);
            Assert.True(account.GetSubscriptions(client.Profile).Any(s => s.Id == new Guid(rdfeSubscription1.SubscriptionId)));
            Assert.True(account.GetSubscriptions(client.Profile).Any(s => s.Id == new Guid(rdfeSubscription2.SubscriptionId)));
            Assert.False(account.GetSubscriptions(client.Profile).Any(s => s.Id == new Guid(csmSubscription1.SubscriptionId)));
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:24,代码来源:ProfileClientTests.cs

示例4: AddAzureAccountWithImpersonatedGuestWithSubscriptions

        public void AddAzureAccountWithImpersonatedGuestWithSubscriptions()
        {
            SetMocks(new[] { rdfeSubscription1, guestRdfeSubscription }.ToList(),
                     new List<CSMSubscription>(),
                     new[] { commonTenant, guestTenant }.ToList(),
                    (userAccount, environment, tenant) =>
                    {
                        var token = new MockAccessToken
                        {
                            UserId = tenant == commonTenant.TenantId ? userAccount.Id : "UserB",
                            AccessToken = "def",
                            LoginType = LoginType.OrgId
                        };
                        userAccount.Id = token.UserId;
                        return token;
                    });
            MemoryDataStore dataStore = new MemoryDataStore();
            dataStore.VirtualStore[oldProfileDataPath] = oldProfileData;
            AzureSession.DataStore = dataStore;
            currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            ProfileClient client = new ProfileClient(currentProfile);

            var account = client.AddAccountAndLoadSubscriptions(new AzureAccount { Id = "UserA", Type = AzureAccount.AccountType.User },
                AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud], null);

            Assert.Equal("UserA", account.Id);
            Assert.Equal(2, account.GetSubscriptions(client.Profile).Count);
            var subrdfe1 = account.GetSubscriptions(client.Profile).FirstOrDefault(s => s.Id == new Guid(rdfeSubscription1.SubscriptionId));
            var userA = client.GetAccount("UserA");
            var userB = client.GetAccount("UserB");
            var subGuest = userB.GetSubscriptions(client.Profile).FirstOrDefault(s => s.Id == new Guid(guestRdfeSubscription.SubscriptionId));
            Assert.NotNull(userA);
            Assert.NotNull(userB);
            Assert.Contains<string>(rdfeSubscription1.SubscriptionId, userA.GetPropertyAsArray(AzureAccount.Property.Subscriptions), StringComparer.OrdinalIgnoreCase);
            Assert.Contains<string>(guestRdfeSubscription.SubscriptionId, userB.GetPropertyAsArray(AzureAccount.Property.Subscriptions), StringComparer.OrdinalIgnoreCase);
            Assert.NotNull(subrdfe1);
            Assert.NotNull(subGuest);
            Assert.Equal("UserA", subrdfe1.Account);
            Assert.Equal("UserB", subGuest.Account);
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:40,代码来源:ProfileClientTests.cs

示例5: AddAzureAccountFiltersEmptyAdClientsInRdfeMode

        public void AddAzureAccountFiltersEmptyAdClientsInRdfeMode()
        {
            var emptyTenantIdrdfeSubscription = new RDFESubscription
            {
                SubscriptionId = "16E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E",
                SubscriptionName = "RdfeSub1",
                SubscriptionStatus = Microsoft.WindowsAzure.Subscriptions.Models.SubscriptionStatus.Active,
                ActiveDirectoryTenantId = ""
            };

            var disabledTenantIdrdfeSubscription = new RDFESubscription
            {
                SubscriptionId = "16E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E",
                SubscriptionName = "RdfeSub1",
                SubscriptionStatus = Microsoft.WindowsAzure.Subscriptions.Models.SubscriptionStatus.Disabled,
                ActiveDirectoryTenantId = "B59BE059-5E3F-463B-8C1A-831A29819B52"
            };
            
            var deletedTenantIdrdfeSubscription = new RDFESubscription
            {
                SubscriptionId = "16E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E",
                SubscriptionName = "RdfeSub1",
                SubscriptionStatus = Microsoft.WindowsAzure.Subscriptions.Models.SubscriptionStatus.Deleted,
                ActiveDirectoryTenantId = "B59BE059-5E3F-463B-8C1A-831A29819B52"
            };

            var deletingTenantIdrdfeSubscription = new RDFESubscription
            {
                SubscriptionId = "16E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E",
                SubscriptionName = "RdfeSub1",
                SubscriptionStatus = Microsoft.WindowsAzure.Subscriptions.Models.SubscriptionStatus.Deleting,
                ActiveDirectoryTenantId = "B59BE059-5E3F-463B-8C1A-831A29819B52"
            };

            SetMocks(
                new[] { rdfeSubscription1, emptyTenantIdrdfeSubscription, disabledTenantIdrdfeSubscription, deletedTenantIdrdfeSubscription, deletingTenantIdrdfeSubscription }.ToList(), 
                new[] { csmSubscription1 }.ToList());
            MemoryDataStore dataStore = new MemoryDataStore();
            dataStore.VirtualStore[oldProfileDataPath] = oldProfileData;
            AzureSession.DataStore = dataStore;
            currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            ProfileClient client = new ProfileClient(currentProfile);

            var account = client.AddAccountAndLoadSubscriptions(
                new AzureAccount { Id = "test", Type = AzureAccount.AccountType.User }, 
                AzureEnvironment.PublicEnvironments[EnvironmentName.AzureCloud], 
                null);

            Assert.Equal("test", account.Id);
            Assert.Equal(1, account.GetSubscriptions(client.Profile).Count);
            Assert.True(account.GetSubscriptions(client.Profile).Any(s => s.Id == new Guid(rdfeSubscription1.SubscriptionId)));
            Assert.False(account.GetSubscriptions(client.Profile).Any(s => s.Id == new Guid(csmSubscription1.SubscriptionId)));
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:53,代码来源:ProfileClientTests.cs


注:本文中的ProfileClient.AddAccountAndLoadSubscriptions方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。