Ejemplo n.º 1
0
 public void InitCommand()
 {
     command = new NewAzureStorageContext
     {
         CommandRuntime = new MockCommandRuntime()
     };
 }
 public void InitCommand()
 {
     command = new NewAzureStorageContext
     {
         CommandRuntime = new MockCommandRuntime()
     };
 }
        public void CanCreateStorageContextEndPoint_SmNotNull_RmNotNull()
        {
            InitSession();
            try
            {
                var mock = new MockCommandRuntime();
                SetSM_RMProfile(isSMProfileNull: false, isRMProfileNull: false);

                AzureSMProfileProvider.Instance.Profile = null;
                AzureRmProfileProvider.Instance.Profile = new TestContextContainer();
                var cmdlet = new NewAzureStorageContext
                {
                    CommandRuntime     = mock,
                    StorageAccountName = "contosostorage",
                    StorageAccountKey  = "AAAAAAAA",
                    Endpoint           = "core.chinacloudapi.cn",
                };

                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);
                Assert.Contains("core.chinacloudapi.cn", storageContext.BlobEndPoint);
            }
            finally
            {
                CleanupSession();
            }
        }
        public void CanCreateStorageContextConnectionString_SmNotNull_RmNotNull()
        {
            InitSession();
            try
            {
                var mock = new MockCommandRuntime();
                SetSM_RMProfile(isSMProfileNull: false, isRMProfileNull: false);

                AzureSMProfileProvider.Instance.Profile = null;
                AzureRmProfileProvider.Instance.Profile = new TestContextContainer();
                var cmdlet = new NewAzureStorageContext
                {
                    CommandRuntime   = mock,
                    ConnectionString = "DefaultEndpointsProtocol=https;AccountName=contosostorage;AccountKey=AAAAAAAA",
                };

                cmdlet.SetParameterSet("ConnectionString");
                cmdlet.ExecuteCmdlet();
                var output = mock.OutputPipeline;
                Assert.NotNull(output);
                var storageContext = output.First() as AzureStorageContext;
                Assert.NotNull(storageContext);
                Assert.Equal("contosostorage", storageContext.StorageAccountName);
            }
            finally
            {
                CleanupSession();
            }
        }
        public void CanCreateStorageContextAnonymous_SmNotNull_RmNotNull()
        {
            InitSession();
            try
            {
                var mock = new MockCommandRuntime();
                SetSM_RMProfile(isSMProfileNull: false, isRMProfileNull: false);

                AzureSMProfileProvider.Instance.Profile = null;
                AzureRmProfileProvider.Instance.Profile = new TestContextContainer();
                var cmdlet = new NewAzureStorageContext
                {
                    CommandRuntime     = mock,
                    StorageAccountName = "contosostorage",
                    Anonymous          = true,
                };

                cmdlet.SetParameterSet("AnonymousAccount");
                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
            {
                CleanupSession();
            }
        }
        public void CanCreateStorageContextInChinaCloud_SmNotNull_RmNotNull()
        {
            InitSession();
            try
            {
                var mock = new MockCommandRuntime();
                SetSM_RMProfile(isSMProfileNull: false, isRMProfileNull: false);

                var cmdlet = new NewAzureStorageContext
                {
                    CommandRuntime     = mock,
                    StorageAccountName = "contosostorage",
                    StorageAccountKey  = "AAAAAAAA",
                    Environment        = EnvironmentName.AzureChinaCloud
                };

                cmdlet.SetParameterSet("AccountNameAndKeyEnvironment");
                cmdlet.ExecuteCmdlet();
                var output = mock.OutputPipeline;
                Assert.NotNull(output);
                var storageContext = output.First() as AzureStorageContext;
                Assert.NotNull(storageContext);
                Assert.Equal(cmdlet.StorageAccountName, storageContext.StorageAccountName);
                Assert.Contains(".cn", storageContext.BlobEndPoint);
            }
            finally
            {
                CleanupSession();
            }
        }
        public void CanCreateStorageContextNameAndKey_SmNotNull_RmNull()
        {
            InitSession();
            try
            {
                var mock = new MockCommandRuntime();
                SetSM_RMProfile(isSMProfileNull: false, isRMProfileNull: true);

                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
            {
                CleanupSession();
            }
        }
        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);
            }
        }
Ejemplo n.º 9
0
 public NewAzureStorageContextTest()
 {
     command = new NewAzureStorageContext
     {
         CommandRuntime = new MockCommandRuntime()
     };
 }
Ejemplo n.º 10
0
 public void CleanCommand()
 {
     command = null;
 }
 public void CleanCommand()
 {
     command = null;
 }