本文整理汇总了C#中ProfileClient.GetAccount方法的典型用法代码示例。如果您正苦于以下问题:C# ProfileClient.GetAccount方法的具体用法?C# ProfileClient.GetAccount怎么用?C# ProfileClient.GetAccount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProfileClient
的用法示例。
在下文中一共展示了ProfileClient.GetAccount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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);
}
示例2: 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);
}