public void TestSetCurrentSubscription()
        {
            var globalComponents = GlobalComponents.CreateFromPublishSettings(GlobalPathInfo.GlobalSettingsDirectory, null, Data.ValidPublishSettings.First());

            var selectSubscriptionCommand = new SelectAzureSubscriptionCommand();

            // Check that current subscription is the default one
            Assert.AreEqual("Windows Azure Sandbox 9-220", selectSubscriptionCommand.GetCurrentSubscription().SubscriptionName);

            // Change it and make sure it got changed
            selectSubscriptionCommand.SelectSubscriptionProcess("Set", "mysub1", Data.ValidSubscriptionsData.First());
            Assert.AreEqual("mysub1", selectSubscriptionCommand.GetCurrentSubscription().SubscriptionName);

            // Clean
            globalComponents.DeleteGlobalComponents();
        }
        public void TestSetCurrentSubscription()
        {
            var globalSettingsManager = GlobalSettingsManager.CreateFromPublishSettings(GlobalPathInfo.GlobalSettingsDirectory, null, Data.ValidPublishSettings.First());

            var selectSubscriptionCommand = new SelectAzureSubscriptionCommand();

            // Check that current subscription is the default one
            Assert.AreEqual("Windows Azure Sandbox 9-220", selectSubscriptionCommand.GetCurrentSubscription().SubscriptionName);

            // Change it and make sure it got changed
            selectSubscriptionCommand.SelectSubscriptionProcess("Set", "mysub1", Data.ValidSubscriptionsData.First());
            Assert.AreEqual("mysub1", selectSubscriptionCommand.GetCurrentSubscription().SubscriptionName);

            // Clean
            globalSettingsManager.DeleteGlobalSettingsManager();
        }
        public void CleansDefaultSubscriptionTwice()
        {
            // Setup
            Mock<ICommandRuntime> commandRuntimeMock = new Mock<ICommandRuntime>();
            SelectAzureSubscriptionCommand cmdlet = new SelectAzureSubscriptionCommand()
            {
                CommandRuntime = commandRuntimeMock.Object,
                PassThru = true,
                NoDefault = true
            };

            // Test
            cmdlet.ExecuteCmdlet();
            cmdlet.ExecuteCmdlet();

            // Assert that no exception is thrown
            Assert.IsTrue(true);
        }
        public void CleansDefaultSubscriptionTwice()
        {
            // Setup
            Mock <ICommandRuntime>         commandRuntimeMock = new Mock <ICommandRuntime>();
            SelectAzureSubscriptionCommand cmdlet             = new SelectAzureSubscriptionCommand()
            {
                CommandRuntime = commandRuntimeMock.Object,
                PassThru       = true,
                NoDefault      = true
            };

            // Test
            cmdlet.ExecuteCmdlet();
            cmdlet.ExecuteCmdlet();

            // Assert that no exception is thrown
            Assert.IsTrue(true);
        }
Esempio n. 5
0
        public void SelectAzureSubscriptionWithoutPassthroughDoesNotPrint()
        {
            SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand();

            SetupDefaultProfile();

            // Setup
            cmdlt.CommandRuntime = commandRuntimeMock;
            cmdlt.SetParameterSet("SelectSubscriptionByNameParameterSet");
            cmdlt.SubscriptionName = azureSubscription2.Name;
            Assert.Null(AzureSession.CurrentContext.Subscription);

            // Act
            cmdlt.InvokeBeginProcessing();
            cmdlt.ExecuteCmdlet();
            cmdlt.InvokeEndProcessing();

            // Verify
            Assert.Equal(0, commandRuntimeMock.OutputPipeline.Count);
        }
Esempio n. 6
0
        public void SelectAzureSubscriptionByNameUpdatesProfile()
        {
            SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand();

            SetupDefaultProfile();

            // Setup
            cmdlt.CommandRuntime = commandRuntimeMock;
            cmdlt.SetParameterSet("SelectSubscriptionByNameParameterSet");
            cmdlt.SubscriptionName = azureSubscription2.Name;
            Assert.Null(AzureSession.CurrentContext.Subscription);

            // Act
            cmdlt.InvokeBeginProcessing();
            cmdlt.ExecuteCmdlet();
            cmdlt.InvokeEndProcessing();

            // Verify
            Assert.NotNull(AzureSession.CurrentContext.Subscription);
            Assert.Equal(azureSubscription2.Id, AzureSession.CurrentContext.Subscription.Id);
        }
Esempio n. 7
0
        public void SelectDefaultAzureSubscriptionByNameUpdatesProfile()
        {
            SelectAzureSubscriptionCommand cmdlt = new SelectAzureSubscriptionCommand();
            var client = SetupDefaultProfile();

            // Setup
            cmdlt.CommandRuntime = commandRuntimeMock;
            cmdlt.SetParameterSet("SelectDefaultSubscriptionByNameParameterSet");
            cmdlt.SubscriptionName = azureSubscription2.Name;
            cmdlt.Default          = new SwitchParameter(true);
            Assert.NotEqual(azureSubscription2.Id, client.Profile.DefaultSubscription.Id);

            // Act
            cmdlt.InvokeBeginProcessing();
            cmdlt.ExecuteCmdlet();
            cmdlt.InvokeEndProcessing();

            // Verify
            client = new ProfileClient();
            Assert.NotNull(client.Profile.DefaultSubscription);
            Assert.Equal(azureSubscription2.Id, client.Profile.DefaultSubscription.Id);
        }