コード例 #1
0
        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);
            }
        }
コード例 #2
0
 private void InitSession()
 {
     AzureSessionInitializer.InitializeAzureSession();
     smProvider = AzureSMProfileProvider.Instance;
     rmProvider = AzureRmProfileProvider.Instance;
     AzureRmProfileProvider.SetInstance(() => new TestProfileProvider(), true);
     AzureSMProfileProvider.SetInstance(() => new TestSMProfileProvider(), true);
 }
コード例 #3
0
 private void CleanupSession()
 {
     AzureSMProfileProvider.SetInstance(() => smProvider, true);
     AzureRmProfileProvider.SetInstance(() => rmProvider, true);
 }