本文整理汇总了C#中ProfileClient.ImportPublishSettings方法的典型用法代码示例。如果您正苦于以下问题:C# ProfileClient.ImportPublishSettings方法的具体用法?C# ProfileClient.ImportPublishSettings怎么用?C# ProfileClient.ImportPublishSettings使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ProfileClient
的用法示例。
在下文中一共展示了ProfileClient.ImportPublishSettings方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PublishContextTests
/// <summary>
/// When running this test double check that the certificate used in Azure.PublishSettings has not expired.
/// </summary>
public PublishContextTests()
{
AzurePowerShell.ProfileDirectory = Test.Utilities.Common.Data.AzureSdkAppDir;
service = new AzureServiceWrapper(Directory.GetCurrentDirectory(), Path.GetRandomFileName(), null);
service.CreateVirtualCloudPackage();
packagePath = service.Paths.CloudPackage;
configPath = service.Paths.CloudConfiguration;
settings = ServiceSettingsTestData.Instance.Data[ServiceSettingsState.Default];
AzureSession.DataStore = new MemoryDataStore();
ProfileClient client = new ProfileClient(new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
AzureSession.DataStore.WriteFile(Test.Utilities.Common.Data.ValidPublishSettings.First(),
File.ReadAllText(Test.Utilities.Common.Data.ValidPublishSettings.First()));
client.ImportPublishSettings(Test.Utilities.Common.Data.ValidPublishSettings.First(), null);
client.Profile.Save();
}
示例2: CreateAzureSdkDirectoryAndImportPublishSettings
/// <summary>
/// Create a temporary Azure SDK directory to simulate global files.
/// </summary>
/// <param name="publishSettingsPath">
/// Path to the publish settings.
/// </param>
/// <returns>The path to the temporary Azure SDK directory.</returns>
public string CreateAzureSdkDirectoryAndImportPublishSettings(string publishSettingsPath)
{
Debug.Assert(!string.IsNullOrEmpty(publishSettingsPath));
Debug.Assert(File.Exists(publishSettingsPath));
Debug.Assert(string.IsNullOrEmpty(AzureSdkPath));
AzureSdkPath = CreateDirectory("AzureSdk");
ProfileClient client = new ProfileClient();
ProfileClient.DataStore.WriteFile(publishSettingsPath, File.ReadAllText(publishSettingsPath));
client.ImportPublishSettings(publishSettingsPath, null);
client.Profile.Save();
return AzureSdkPath;
}
示例3: ImportPublishSettingsFileOverwritesEnvironment
public void ImportPublishSettingsFileOverwritesEnvironment()
{
ImportAzurePublishSettingsCommand cmdlt = new ImportAzurePublishSettingsCommand();
// Setup
ProfileClient.DataStore.WriteFile("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings",
Properties.Resources.ValidProfileChina);
ProfileClient client = new ProfileClient();
var oldDataStore = FileUtilities.DataStore;
FileUtilities.DataStore = ProfileClient.DataStore;
var expectedEnv = "AzureCloud";
var expected = client.ImportPublishSettings("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings", expectedEnv);
cmdlt.CommandRuntime = commandRuntimeMock.Object;
cmdlt.ProfileClient = new ProfileClient();
cmdlt.PublishSettingsFile = "ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings";
cmdlt.Environment = expectedEnv;
try
{
// Act
cmdlt.InvokeBeginProcessing();
cmdlt.ExecuteCmdlet();
cmdlt.InvokeEndProcessing();
// Verify
foreach (var subscription in expected)
{
Assert.Equal(cmdlt.ProfileClient.GetSubscription(subscription.Id).Environment, expectedEnv);
}
commandRuntimeMock.Verify(f => f.WriteObject(expected), Times.Once());
}
finally
{
// Cleanup
FileUtilities.DataStore = oldDataStore;
}
}
示例4: ImportPublishSettingsAddsSecondCertificate
public void ImportPublishSettingsAddsSecondCertificate()
{
MockDataStore dataStore = new MockDataStore();
ProfileClient.DataStore = dataStore;
ProfileClient client = new ProfileClient();
var newSubscription = new AzureSubscription
{
Id = new Guid("f62b1e05-af8f-4203-8f97-421089adc053"),
Name = "Microsoft Azure Sandbox 9-220",
Environment = EnvironmentName.AzureCloud,
Account = azureAccount.Id
};
azureAccount.SetProperty(AzureAccount.Property.Subscriptions, newSubscription.Id.ToString());
client.AddOrSetAccount(azureAccount);
client.AddOrSetSubscription(newSubscription);
client.Profile.Save();
client = new ProfileClient();
dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings",
Properties.Resources.ValidProfile);
client.AddOrSetEnvironment(azureEnvironment);
var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", azureEnvironment.Name);
Assert.Equal(2, client.Profile.Accounts.Count());
var certAccount = client.Profile.Accounts.Values.First(a => a.Type == AzureAccount.AccountType.Certificate);
var userAccount = client.Profile.Accounts.Values.First(a => a.Type == AzureAccount.AccountType.User);
Assert.True(subscriptions.All(s => s.Account == certAccount.Id));
Assert.Equal(azureAccount.Id, client.Profile.Subscriptions.Values.First(s => s.Id == newSubscription.Id).Account);
Assert.True(userAccount.GetPropertyAsArray(AzureAccount.Property.Subscriptions).Contains(newSubscription.Id.ToString()));
Assert.True(certAccount.GetPropertyAsArray(AzureAccount.Property.Subscriptions).Contains(newSubscription.Id.ToString()));
Assert.Equal(6, subscriptions.Count);
Assert.Equal(6, client.Profile.Subscriptions.Count);
}
示例5: ImportPublishSettingsUsesPassedInEnvironment
public void ImportPublishSettingsUsesPassedInEnvironment()
{
MockDataStore dataStore = new MockDataStore();
ProfileClient.DataStore = dataStore;
ProfileClient client = new ProfileClient();
client.AddOrSetAccount(azureAccount);
client.AddOrSetEnvironment(azureEnvironment);
client.AddOrSetSubscription(azureSubscription1);
client.SetSubscriptionAsDefault(azureSubscription1.Name, azureAccount.Id);
client.Profile.Save();
client = new ProfileClient();
dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings",
Properties.Resources.ValidProfile3);
client.AddOrSetEnvironment(azureEnvironment);
var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", azureEnvironment.Name);
Assert.True(subscriptions.All(s => s.Environment == azureEnvironment.Name));
Assert.Equal(6, subscriptions.Count);
Assert.Equal(7, client.Profile.Subscriptions.Count);
}
示例6: ImportPublishSettingsUsesProperEnvironmentWithChinaManagementUrlOld
public void ImportPublishSettingsUsesProperEnvironmentWithChinaManagementUrlOld()
{
MockDataStore dataStore = new MockDataStore();
ProfileClient.DataStore = dataStore;
ProfileClient client = new ProfileClient();
dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings",
Properties.Resources.ValidProfileChinaOld);
client.AddOrSetEnvironment(azureEnvironment);
var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", null);
Assert.True(subscriptions.All(s => s.Environment == EnvironmentName.AzureChinaCloud));
Assert.Equal(1, subscriptions.Count);
Assert.Equal(1, client.Profile.Subscriptions.Count);
}
示例7: ImportPublishSettingsUsesProperEnvironmentWithManagementUrl
public void ImportPublishSettingsUsesProperEnvironmentWithManagementUrl()
{
MockDataStore dataStore = new MockDataStore();
ProfileClient.DataStore = dataStore;
ProfileClient client = new ProfileClient();
client.AddOrSetAccount(azureAccount);
azureEnvironment.Endpoints[AzureEnvironment.Endpoint.ServiceManagement] = "https://newmanagement.core.windows.net/";
client.AddOrSetEnvironment(azureEnvironment);
client.AddOrSetSubscription(azureSubscription1);
client.SetSubscriptionAsDefault(azureSubscription1.Name, azureAccount.Id);
client.Profile.Save();
client = new ProfileClient();
dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings",
Properties.Resources.ValidProfile3);
client.AddOrSetEnvironment(azureEnvironment);
var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", null);
Assert.True(subscriptions.All(s => s.Environment == azureEnvironment.Name));
Assert.Equal(6, subscriptions.Count);
Assert.Equal(7, client.Profile.Subscriptions.Count);
}
示例8: ImportPublishSettingsLoadsAndReturnsSubscriptions
public void ImportPublishSettingsLoadsAndReturnsSubscriptions()
{
MockDataStore dataStore = new MockDataStore();
ProfileClient.DataStore = dataStore;
ProfileClient client = new ProfileClient();
dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings",
Properties.Resources.ValidProfile);
client.AddOrSetEnvironment(azureEnvironment);
var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", azureEnvironment.Name);
var account = client.Profile.Accounts.Values.First();
Assert.True(subscriptions.All(s => s.Account == account.Id));
Assert.Equal(6, subscriptions.Count);
Assert.Equal(6, client.Profile.Subscriptions.Count);
}
示例9: 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;
}
}