本文整理汇总了C#中Microsoft.Azure.Common.Authentication.ProfileClient.RemoveSubscription方法的典型用法代码示例。如果您正苦于以下问题:C# ProfileClient.RemoveSubscription方法的具体用法?C# ProfileClient.RemoveSubscription怎么用?C# ProfileClient.RemoveSubscription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Microsoft.Azure.Common.Authentication.ProfileClient
的用法示例。
在下文中一共展示了ProfileClient.RemoveSubscription方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: RemoveAzureSubscriptionChecksAndRemoves
public void RemoveAzureSubscriptionChecksAndRemoves()
{
MemoryDataStore dataStore = new MemoryDataStore();
AzureSession.DataStore = dataStore;
currentProfile = new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
ProfileClient client = new ProfileClient(currentProfile);
client.Profile.Accounts[azureAccount.Id] = azureAccount;
client.AddOrSetEnvironment(azureEnvironment);
client.AddOrSetSubscription(azureSubscription1);
client.SetSubscriptionAsDefault(azureSubscription1.Name, azureSubscription1.Account);
Assert.Equal(1, client.Profile.Subscriptions.Count);
List<string> log = new List<string>();
client.WarningLog = log.Add;
var subscription = client.RemoveSubscription(azureSubscription1.Name);
Assert.Equal(0, client.Profile.Subscriptions.Count);
Assert.Equal(azureSubscription1.Name, subscription.Name);
Assert.Equal(1, log.Count);
Assert.Equal(
"The default subscription is being removed. Use Select-AzureSubscription -Default <subscriptionName> to select a new default subscription.",
log[0]);
Assert.Throws<ArgumentException>(() => client.RemoveSubscription("bad"));
Assert.Throws<ArgumentNullException>(() => client.RemoveSubscription(null));
}