public void CanCreateStorageContextNameAndKey() { AzureSessionInitializer.InitializeAzureSession(); var smProvider = AzureSMProfileProvider.Instance; var rmProvider = AzureRmProfileProvider.Instance; AzureRmProfileProvider.SetInstance(() => new TestProfileProvider(), true); AzureSMProfileProvider.SetInstance(() => new TestSMProfileProvider(), true); try { var mock = new MockCommandRuntime(); AzureSMProfileProvider.Instance.Profile = null; AzureRmProfileProvider.Instance.Profile = new TestContextContainer(); var cmdlet = new NewAzureStorageContext { CommandRuntime = mock, StorageAccountName = "contosostorage", StorageAccountKey = "AAAAAAAA", }; cmdlet.SetParameterSet("AccountNameAndKey"); cmdlet.ExecuteCmdlet(); var output = mock.OutputPipeline; Assert.NotNull(output); var storageContext = output.First() as AzureStorageContext; Assert.NotNull(storageContext); Assert.Equal(cmdlet.StorageAccountName, storageContext.StorageAccountName); } finally { AzureSMProfileProvider.SetInstance(() => smProvider, true); AzureRmProfileProvider.SetInstance(() => rmProvider, true); } }
private void InitSession() { AzureSessionInitializer.InitializeAzureSession(); smProvider = AzureSMProfileProvider.Instance; rmProvider = AzureRmProfileProvider.Instance; AzureRmProfileProvider.SetInstance(() => new TestProfileProvider(), true); AzureSMProfileProvider.SetInstance(() => new TestSMProfileProvider(), true); }
private void CleanupSession() { AzureSMProfileProvider.SetInstance(() => smProvider, true); AzureRmProfileProvider.SetInstance(() => rmProvider, true); }