コード例 #1
0
        public void TestGetCurrentSubscriptionByName()
        {
            var globalComponents = GlobalComponents.CreateFromPublishSettings(GlobalPathInfo.GlobalSettingsDirectory, null, Data.ValidPublishSettings.First());

            var importSubscriptionCommand = new ImportAzurePublishSettingsCommand();
            importSubscriptionCommand.ImportSubscriptionFile(
                Data.ValidPublishSettings.First(),
                null);

            var currentSubscription = importSubscriptionCommand.GetCurrentSubscription();
            Assert.AreEqual(currentSubscription.SubscriptionName, Data.Subscription1);
            Assert.IsTrue(currentSubscription.IsDefault);

            // Test the get for all subscription (null name)
            var getSubscriptionCommand = new GetSubscriptionCommandStub();
            getSubscriptionCommand.GetSubscriptionProcess("ByName", null, null);

            Assert.AreEqual(6, getSubscriptionCommand.Messages.Count);

            // Test the get for a specific susbcription
            getSubscriptionCommand = new GetSubscriptionCommandStub();
            getSubscriptionCommand.GetSubscriptionProcess("ByName", currentSubscription.SubscriptionName, null);

            Assert.AreEqual(1, getSubscriptionCommand.Messages.Count);
            Assert.AreEqual(currentSubscription.SubscriptionName, getSubscriptionCommand.Messages.First().SubscriptionName);
            Assert.AreEqual(currentSubscription.SubscriptionId, getSubscriptionCommand.Messages.First().SubscriptionId);

            globalComponents.DeleteGlobalComponents();
        }
コード例 #2
0
        public void TestImportSubscriptionPublishSettingsSecondVersionOnlyProcess()
        {
            MockCommandRuntime mockCommandRuntime;
            ImportAzurePublishSettingsCommand cmdlet;
            mockCommandRuntime = new MockCommandRuntime();
            cmdlet = new ImportAzurePublishSettingsCommand();
            cmdlet.CommandRuntime = mockCommandRuntime;
            cmdlet.SubscriptionClient = CreateMockSubscriptionClient();
            cmdlet.ImportSubscriptionFile(
                Data.ValidPublishSettings2.First(),
                null);

            var currentSubscription = cmdlet.GetCurrentSubscription();
            Assert.AreEqual(Data.SampleSubscription1, currentSubscription.SubscriptionName);
            Assert.AreEqual("https://newmanagement.core.windows.net/", currentSubscription.ServiceEndpoint);
            Assert.IsNotNull(currentSubscription.Certificate);
            Assert.IsTrue(currentSubscription.IsDefault);
        }
コード例 #3
0
        public void TestImportSubscriptionPublishSettingsOnlyProcess()
        {
            MockCommandRuntime mockCommandRuntime;
            ImportAzurePublishSettingsCommand cmdlet;
            mockCommandRuntime = new MockCommandRuntime();
            cmdlet = new ImportAzurePublishSettingsCommand();
            cmdlet.CommandRuntime = mockCommandRuntime;
            cmdlet.ImportSubscriptionFile(
                Data.ValidPublishSettings.First(),
                null);

            var currentSubscription = cmdlet.GetCurrentSubscription();
            Assert.AreEqual(Data.Subscription1, currentSubscription.SubscriptionName);
            Assert.IsTrue(currentSubscription.IsDefault);
        }
コード例 #4
0
        public void TestImportSubscriptionPublishSettingsOnlyMultipleTimesProcess()
        {
            MockCommandRuntime mockCommandRuntime;
            ImportAzurePublishSettingsCommand cmdlet;
            mockCommandRuntime = new MockCommandRuntime();
            cmdlet = new ImportAzurePublishSettingsCommand();
            cmdlet.CommandRuntime = mockCommandRuntime;
            cmdlet.SubscriptionClient = CreateMockSubscriptionClient();
            cmdlet.ImportSubscriptionFile(
                Data.ValidPublishSettings.First(),
                null);

            var subscriptions = cmdlet.GetSubscriptions(null);

            SubscriptionData currentSubscription = cmdlet.GetCurrentSubscription();
            Assert.AreEqual(Data.Subscription1, currentSubscription.SubscriptionName);
            Assert.IsTrue(currentSubscription.IsDefault);

            SubscriptionData newCurrentSubscription = subscriptions.Values.FirstOrDefault(s => !s.SubscriptionId.Equals(currentSubscription.SubscriptionId));
            cmdlet.SetCurrentSubscription(newCurrentSubscription);

            cmdlet.ImportSubscriptionFile(
                Data.ValidPublishSettings.First(),
                null);

            currentSubscription = cmdlet.GetCurrentSubscription();
            Assert.AreEqual(currentSubscription.SubscriptionId, newCurrentSubscription.SubscriptionId);
        }
コード例 #5
0
        public void TestImportSubscriptionProcess()
        {
            MockCommandRuntime mockCommandRuntime;
            ImportAzurePublishSettingsCommand cmdlet;
            mockCommandRuntime = new MockCommandRuntime();
            cmdlet = new ImportAzurePublishSettingsCommand();
            cmdlet.CommandRuntime = mockCommandRuntime;
            var globalComponents = GlobalComponents.CreateFromPublishSettings(GlobalPathInfo.GlobalSettingsDirectory, null, Data.ValidPublishSettings.First());

            cmdlet.ImportSubscriptionFile(
                Data.ValidPublishSettings.First(),
                null);

            var currentSubscription = cmdlet.GetCurrentSubscription();
            Assert.AreEqual(currentSubscription.SubscriptionName, Data.Subscription1);
            Assert.IsTrue(currentSubscription.IsDefault);

            globalComponents.DeleteGlobalComponents();
        }
コード例 #6
0
        public void TestGetCurrentSubscriptionCurrent()
        {
            var globalSettingsManager = GlobalSettingsManager.CreateFromPublishSettings(GlobalPathInfo.GlobalSettingsDirectory, null, Data.ValidPublishSettings.First());

            var importSubscriptionCommand = new ImportAzurePublishSettingsCommand();
            importSubscriptionCommand.ImportSubscriptionFile(
                Data.ValidPublishSettings.First(),
                null);

            var currentSubscription = importSubscriptionCommand.GetCurrentSubscription();
            Assert.AreEqual(currentSubscription.SubscriptionName, Data.Subscription1);
            Assert.IsTrue(currentSubscription.IsDefault);

            // Test the get for the current subscription
            var getSubscriptionCommand = new GetSubscriptionCommandStub();
            getSubscriptionCommand.GetSubscriptionProcess("Current", null, null);

            Assert.AreEqual(1, getSubscriptionCommand.Messages.Count);
            Assert.AreEqual(currentSubscription.SubscriptionName, getSubscriptionCommand.Messages.First().SubscriptionName);
            Assert.AreEqual(currentSubscription.SubscriptionId, getSubscriptionCommand.Messages.First().SubscriptionId);

            globalSettingsManager.DeleteGlobalSettingsManager();
        }
コード例 #7
0
        public void TestInitialize()
        {
            CmdletSubscriptionExtensions.SessionManager = new InMemorySessionManager();

            serviceName = Path.GetRandomFileName();
            GlobalPathInfo.GlobalSettingsDirectory = 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];
            mockCommandRuntime = new MockCommandRuntime();
            importCmdlet = new ImportAzurePublishSettingsCommand();
            importCmdlet.CommandRuntime = mockCommandRuntime;
            importCmdlet.ImportSubscriptionFile(Data.ValidPublishSettings.First(), null);
            importCmdlet.SubscriptionClient = CreateMockSubscriptionClient();
        }