本文整理汇总了C#中ProfileClient.GetSubscription方法的典型用法代码示例。如果您正苦于以下问题:C# ProfileClient.GetSubscription方法的具体用法?C# ProfileClient.GetSubscription怎么用?C# ProfileClient.GetSubscription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProfileClient
的用法示例。
在下文中一共展示了ProfileClient.GetSubscription方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetAzureSubscriptionByIdChecksAndReturnsOnlyLocal
public void GetAzureSubscriptionByIdChecksAndReturnsOnlyLocal()
{
SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1, csmSubscription1withDuplicateId }.ToList());
MockDataStore dataStore = new MockDataStore();
ProfileClient.DataStore = dataStore;
ProfileClient client = new ProfileClient();
client.AddOrSetAccount(azureAccount);
PowerShellUtilities.GetCurrentModeOverride = () => AzureModule.AzureResourceManager;
client.AddOrSetEnvironment(azureEnvironment);
client.AddOrSetSubscription(azureSubscription1);
client.AddOrSetSubscription(azureSubscription2);
var subscriptions = client.GetSubscription(azureSubscription1.Id);
Assert.Equal(azureSubscription1.Id, subscriptions.Id);
Assert.Throws<ArgumentException>(() => client.GetSubscription(new Guid()));
}
示例2: GetAzureSubscriptionByIdChecksAndReturnsOnlyLocal
public void GetAzureSubscriptionByIdChecksAndReturnsOnlyLocal()
{
SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1, csmSubscription1withDuplicateId }.ToList());
MemoryDataStore dataStore = new MemoryDataStore();
AzureSession.DataStore = dataStore;
currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
ProfileClient client = new ProfileClient(currentProfile);
client.AddOrSetAccount(azureAccount);
client.AddOrSetEnvironment(azureEnvironment);
client.AddOrSetSubscription(azureSubscription1);
client.AddOrSetSubscription(azureSubscription2);
var subscriptions = client.GetSubscription(azureSubscription1.Id);
Assert.Equal(azureSubscription1.Id, subscriptions.Id);
Assert.Throws<ArgumentException>(() => client.GetSubscription(new Guid()));
}
示例3: ImportPublishSettingsWorksForCustomProfile
public void ImportPublishSettingsWorksForCustomProfile()
{
ImportAzurePublishSettingsCommand cmdlt = new ImportAzurePublishSettingsCommand();
var oldAzureDataStore = AzureSession.DataStore;
AzureSession.DataStore = new MemoryDataStore();
// Setup
AzureSession.DataStore.WriteFile("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings",
Commands.Common.Test.Properties.Resources.ValidProfileChina);
var oldProfile = new AzureProfile();
AzurePSCmdlet.CurrentProfile = oldProfile;
var profile = new AzureProfile();
ProfileClient client = new ProfileClient(profile);
var oldDataStore = FileUtilities.DataStore;
FileUtilities.DataStore = AzureSession.DataStore;
var expectedEnv = "AzureCloud";
var expected = client.ImportPublishSettings("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings", expectedEnv);
AzurePSCmdlet.CurrentProfile = new AzureProfile();
cmdlt.Profile = profile;
cmdlt.CommandRuntime = commandRuntimeMock;
cmdlt.ProfileClient = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
cmdlt.PublishSettingsFile = "ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings";
cmdlt.Environment = expectedEnv;
try
{
// Act
cmdlt.InvokeBeginProcessing();
cmdlt.ExecuteCmdlet();
cmdlt.InvokeEndProcessing();
// Verify
foreach (var subscription in expected)
{
Assert.Equal(client.GetSubscription(subscription.Id).Environment, expectedEnv);
}
Assert.Equal(1, commandRuntimeMock.OutputPipeline.Count);
Assert.Equal(oldProfile.Subscriptions.Count, 0);
Assert.Equal(oldProfile.Accounts.Count, 0);
}
finally
{
// Cleanup
FileUtilities.DataStore = oldDataStore;
AzureSession.DataStore = oldAzureDataStore;
}
}
示例4: GetAzureSubscriptionByNameChecksAndReturnsOnlyLocal
public void GetAzureSubscriptionByNameChecksAndReturnsOnlyLocal()
{
SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1, csmSubscription1withDuplicateId }.ToList());
MockDataStore dataStore = new MockDataStore();
ProfileClient.DataStore = dataStore;
ProfileClient client = new ProfileClient();
client.AddOrSetAccount(azureAccount);
client.AddOrSetEnvironment(azureEnvironment);
client.AddOrSetSubscription(azureSubscription1);
client.AddOrSetSubscription(azureSubscription2);
var subscriptions = client.GetSubscription(azureSubscription1.Name);
Assert.Equal(azureSubscription1.Id, subscriptions.Id);
Assert.Throws<ArgumentException>(() => client.GetSubscription(new Guid()));
}