Esempio n. 1
0
        public void TestImportPublishSettingsWithoutPassingDirectory()
        {
            MockCommandRuntime mockCommandRuntime;
            ImportAzurePublishSettingsCommand cmdlet;

            mockCommandRuntime        = new MockCommandRuntime();
            cmdlet                    = new ImportAzurePublishSettingsCommand();
            cmdlet.CommandRuntime     = mockCommandRuntime;
            cmdlet.SubscriptionClient = CreateMockSubscriptionClient();
            string directoryName = "testdir";
            string fileName      = "myfile.publishsettings";

            Directory.CreateDirectory(directoryName);
            string originalDirectory = Directory.GetCurrentDirectory();

            Directory.SetCurrentDirectory(Path.GetFullPath(directoryName));
            File.WriteAllText(fileName, File.ReadAllText(Data.ValidPublishSettings.First()));

            cmdlet.ExecuteCmdlet();

            SubscriptionData currentSubscription = cmdlet.GetCurrentSubscription();

            Assert.AreEqual(currentSubscription.SubscriptionName, Data.Subscription1);
            Assert.IsTrue(currentSubscription.IsDefault);
            Assert.AreEqual <string>(Path.GetFullPath(fileName), mockCommandRuntime.OutputPipeline[0].ToString());
            Directory.SetCurrentDirectory(originalDirectory);
            Assert.AreEqual <string>(originalDirectory, Directory.GetCurrentDirectory());
        }
        public void TestGetCurrentSubscriptionDefault()
        {
            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("Default", 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();
        }
Esempio n. 3
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);
        }
        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(3, 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();
        }
        public void TestImportPublishSettingsWithMultiplePublishSettingsFilesFound()
        {
            MockCommandRuntime mockCommandRuntime;
            ImportAzurePublishSettingsCommand cmdlet;
            mockCommandRuntime = new MockCommandRuntime();
            cmdlet = new ImportAzurePublishSettingsCommand();
            cmdlet.CommandRuntime = mockCommandRuntime;
            string directoryName = "testdir2";
            string fileName1 = "myfile1.publishsettings";
            string fileName2 = "myfile2.publishsettings";
            string filePath1 = Path.Combine(directoryName, fileName1);
            string filePath2 = Path.Combine(directoryName, fileName2);
            Directory.CreateDirectory(directoryName);
            File.WriteAllText(filePath1, File.ReadAllText(Data.ValidPublishSettings.First()));
            File.WriteAllText(filePath2, File.ReadAllText(Data.ValidPublishSettings.First()));
            cmdlet.PublishSettingsFile = directoryName;

            cmdlet.ExecuteCmdlet();

            SubscriptionData currentSubscription = cmdlet.GetCurrentSubscription();
            Assert.AreEqual(currentSubscription.SubscriptionName, Data.Subscription1);
            Assert.IsTrue(currentSubscription.IsDefault);
            Assert.AreEqual<string>(filePath1, mockCommandRuntime.OutputPipeline[0].ToString());
            Assert.AreEqual<string>(string.Format(Resources.MultiplePublishSettingsFilesFoundMessage, filePath1), mockCommandRuntime.WarningStream[0]);
        }
        public void TestGetCurrentSubscriptionByName()
        {
            var globalComponents = GlobalComponents.CreateFromPublishSettings(GlobalPathInfo.GlobalSettingsDirectory, null, Data.ValidPublishSettings.First());

            var importSubscriptionCommand = new ImportAzurePublishSettingsCommand();

            importSubscriptionCommand.ImportSubscriptionProcess(
                Data.ValidPublishSettings.First(),
                null);

            var currentSubscription = importSubscriptionCommand.GetCurrentSubscription();

            Assert.AreEqual(currentSubscription.SubscriptionName, "Windows Azure Sandbox 9-220");
            Assert.IsTrue(currentSubscription.IsDefault);

            // Test the get for all subscription (null name)
            var getSubscriptionCommand = new GetSubscriptionCommandStub();

            getSubscriptionCommand.GetSubscriptionProcess("ByName", null, null);

            Assert.AreEqual(3, 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();
        }
Esempio n. 7
0
        public void TestImportPublishSettingsWithMultiplePublishSettingsFilesFound()
        {
            MockCommandRuntime mockCommandRuntime;
            ImportAzurePublishSettingsCommand cmdlet;

            mockCommandRuntime        = new MockCommandRuntime();
            cmdlet                    = new ImportAzurePublishSettingsCommand();
            cmdlet.CommandRuntime     = mockCommandRuntime;
            cmdlet.SubscriptionClient = CreateMockSubscriptionClient();
            string directoryName = "testdir2";
            string fileName1     = "myfile1.publishsettings";
            string fileName2     = "myfile2.publishsettings";
            string filePath1     = Path.Combine(directoryName, fileName1);
            string filePath2     = Path.Combine(directoryName, fileName2);

            Directory.CreateDirectory(directoryName);
            File.WriteAllText(filePath1, File.ReadAllText(Data.ValidPublishSettings.First()));
            File.WriteAllText(filePath2, File.ReadAllText(Data.ValidPublishSettings.First()));
            cmdlet.PublishSettingsFile = directoryName;

            cmdlet.ExecuteCmdlet();

            SubscriptionData currentSubscription = cmdlet.GetCurrentSubscription();

            Assert.AreEqual(currentSubscription.SubscriptionName, Data.Subscription1);
            Assert.IsTrue(currentSubscription.IsDefault);
            Assert.AreEqual <string>(filePath1, mockCommandRuntime.OutputPipeline[0].ToString());
            Assert.AreEqual <string>(string.Format(Resources.MultiplePublishSettingsFilesFoundMessage, filePath1), mockCommandRuntime.WarningStream[0]);
        }
 public void Setup()
 {
     mockCommandRuntime = new MockCommandRuntime();
     profile = new WindowsAzureProfile(new Mock<IProfileStore>().Object);
     cmdlet = new ImportAzurePublishSettingsCommand
     {
         Profile = profile,
         CommandRuntime = mockCommandRuntime
     };
 }
Esempio n. 9
0
 public void Setup()
 {
     mockCommandRuntime = new MockCommandRuntime();
     profile            = new WindowsAzureProfile(new Mock <IProfileStore>().Object);
     cmdlet             = new ImportAzurePublishSettingsCommand
     {
         Profile        = profile,
         CommandRuntime = mockCommandRuntime
     };
 }
        public void TestImportSubscriptionPublishSettingsOnlyProcess()
        {
            var importSubscriptionCommand = new ImportAzurePublishSettingsCommand();
            importSubscriptionCommand.ImportSubscriptionProcess(
                Data.ValidPublishSettings.First(),
                null);

            var currentSubscription = importSubscriptionCommand.GetCurrentSubscription();
            Assert.AreEqual("Windows Azure Sandbox 9-220", currentSubscription.SubscriptionName);
            Assert.IsTrue(currentSubscription.IsDefault);
        }
        public void TestImportSubscriptionPublishSettingsOnlyProcess()
        {
            var importSubscriptionCommand = new ImportAzurePublishSettingsCommand();

            importSubscriptionCommand.ImportSubscriptionProcess(
                Data.ValidPublishSettings.First(),
                null);

            var currentSubscription = importSubscriptionCommand.GetCurrentSubscription();

            Assert.AreEqual("Windows Azure Sandbox 9-220", currentSubscription.SubscriptionName);
            Assert.IsTrue(currentSubscription.IsDefault);
        }
        public void TestImportSubscriptionProcess()
        {
            var globalComponents = GlobalComponents.CreateFromPublishSettings(GlobalPathInfo.GlobalSettingsDirectory, null, Data.ValidPublishSettings.First());

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

            var currentSubscription = importSubscriptionCommand.GetCurrentSubscription();
            Assert.AreEqual(currentSubscription.SubscriptionName, "Windows Azure Sandbox 9-220");
            Assert.IsTrue(currentSubscription.IsDefault);

            globalComponents.DeleteGlobalComponents();
        }
Esempio n. 13
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();
        }
        public void TestImportSubscriptionProcess()
        {
            var globalComponents = GlobalComponents.CreateFromPublishSettings(GlobalPathInfo.GlobalSettingsDirectory, null, Data.ValidPublishSettings.First());

            var importSubscriptionCommand = new ImportAzurePublishSettingsCommand();

            importSubscriptionCommand.ImportSubscriptionProcess(
                Data.ValidPublishSettings.First(),
                null);

            var currentSubscription = importSubscriptionCommand.GetCurrentSubscription();

            Assert.AreEqual(currentSubscription.SubscriptionName, "Windows Azure Sandbox 9-220");
            Assert.IsTrue(currentSubscription.IsDefault);

            globalComponents.DeleteGlobalComponents();
        }
Esempio n. 15
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);
        }
        public void TestImportPublishSettingsWithNoPublishSettingsFilesFound()
        {
            MockCommandRuntime mockCommandRuntime;
            ImportAzurePublishSettingsCommand cmdlet;
            mockCommandRuntime = new MockCommandRuntime();
            cmdlet = new ImportAzurePublishSettingsCommand();
            cmdlet.CommandRuntime = mockCommandRuntime;
            string directoryName = "testdir3";
            string originalDirectory = Directory.GetCurrentDirectory();
            Directory.CreateDirectory(directoryName);
            Directory.SetCurrentDirectory(Path.GetFullPath(directoryName));

            Testing.AssertThrows<Exception>(
                () => cmdlet.ExecuteCmdlet(),
                string.Format(Resources.NoPublishSettingsFilesFoundMessage, Directory.GetCurrentDirectory()));
            Directory.SetCurrentDirectory(originalDirectory);
            Assert.AreEqual<string>(originalDirectory, Directory.GetCurrentDirectory());
        }
Esempio n. 17
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);
        }
Esempio n. 18
0
        public void TestImportPublishSettingsWithNoPublishSettingsFilesFound()
        {
            MockCommandRuntime mockCommandRuntime;
            ImportAzurePublishSettingsCommand cmdlet;

            mockCommandRuntime        = new MockCommandRuntime();
            cmdlet                    = new ImportAzurePublishSettingsCommand();
            cmdlet.CommandRuntime     = mockCommandRuntime;
            cmdlet.SubscriptionClient = CreateMockSubscriptionClient();
            string directoryName     = "testdir3";
            string originalDirectory = Directory.GetCurrentDirectory();

            Directory.CreateDirectory(directoryName);
            Directory.SetCurrentDirectory(Path.GetFullPath(directoryName));

            Testing.AssertThrows <Exception>(
                () => cmdlet.ExecuteCmdlet(),
                string.Format(Resources.NoPublishSettingsFilesFoundMessage, Directory.GetCurrentDirectory()));
            Directory.SetCurrentDirectory(originalDirectory);
            Assert.AreEqual <string>(originalDirectory, Directory.GetCurrentDirectory());
        }
Esempio n. 19
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();
        }
Esempio n. 20
0
        public void ImportPublishSettingsFileOverwritesEnvironment()
        {
            ImportAzurePublishSettingsCommand cmdlt = new ImportAzurePublishSettingsCommand();

            // Setup
            ProfileClient.DataStore.WriteFile("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings",
                                              Properties.Resources.ValidProfileChina);
            ProfileClient client       = new ProfileClient();
            var           oldDataStore = FileUtilities.DataStore;

            FileUtilities.DataStore = ProfileClient.DataStore;
            var expectedEnv = "AzureCloud";
            var expected    = client.ImportPublishSettings("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings", expectedEnv);

            cmdlt.CommandRuntime      = commandRuntimeMock.Object;
            cmdlt.ProfileClient       = new ProfileClient();
            cmdlt.PublishSettingsFile = "ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings";
            cmdlt.Environment         = expectedEnv;

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

                // Verify
                foreach (var subscription in expected)
                {
                    Assert.Equal(cmdlt.ProfileClient.GetSubscription(subscription.Id).Environment, expectedEnv);
                }
                commandRuntimeMock.Verify(f => f.WriteObject(expected), Times.Once());
            }
            finally
            {
                // Cleanup
                FileUtilities.DataStore = oldDataStore;
            }
        }
        public void TestImportSubscriptionPublishSettingsOnlyMultipleTimesProcess()
        {
            var importSubscriptionCommand = new ImportAzurePublishSettingsCommand();
            importSubscriptionCommand.ImportSubscriptionProcess(
                Data.ValidPublishSettings.First(),
                null);

            var subscriptions = importSubscriptionCommand.GetSubscriptions(null);

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

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

            importSubscriptionCommand.ImportSubscriptionProcess(
                Data.ValidPublishSettings.First(),
                null);

            currentSubscription = importSubscriptionCommand.GetCurrentSubscription();
            Assert.AreEqual(currentSubscription.SubscriptionId, newCurrentSubscription.SubscriptionId);
        }
        public void TestImportSubscriptionPublishSettingsSecondVersionOnlyProcess()
        {
            var importSubscriptionCommand = new ImportAzurePublishSettingsCommand();
            importSubscriptionCommand.ImportSubscriptionProcess(
                Data.ValidPublishSettings2.First(),
                null);

            var currentSubscription = importSubscriptionCommand.GetCurrentSubscription();
            Assert.AreEqual(Data.SampleSubscription1, currentSubscription.SubscriptionName);
            Assert.AreEqual("https://newmanagement.core.windows.net/", currentSubscription.ServiceEndpoint);
            Assert.IsNotNull(currentSubscription.Certificate);
            Assert.IsTrue(currentSubscription.IsDefault);
        }
        public void TestInitialize()
        {
            Management.Extensions.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);
        }
        public void TestImportPublishSettingsWithoutPassingDirectory()
        {
            MockCommandRuntime mockCommandRuntime;
            ImportAzurePublishSettingsCommand cmdlet;
            mockCommandRuntime = new MockCommandRuntime();
            cmdlet = new ImportAzurePublishSettingsCommand();
            cmdlet.CommandRuntime = mockCommandRuntime;
            string directoryName = "testdir";
            string fileName = "myfile.publishsettings";
            Directory.CreateDirectory(directoryName);
            string originalDirectory = Directory.GetCurrentDirectory();
            Directory.SetCurrentDirectory(Path.GetFullPath(directoryName));
            File.WriteAllText(fileName, File.ReadAllText(Data.ValidPublishSettings.First()));

            cmdlet.ExecuteCmdlet();

            SubscriptionData currentSubscription = cmdlet.GetCurrentSubscription();
            Assert.AreEqual(currentSubscription.SubscriptionName, Data.Subscription1);
            Assert.IsTrue(currentSubscription.IsDefault);
            Assert.AreEqual<string>(Path.GetFullPath(fileName), mockCommandRuntime.OutputPipeline[0].ToString());
            Directory.SetCurrentDirectory(originalDirectory);
            Assert.AreEqual<string>(originalDirectory, Directory.GetCurrentDirectory());
        }
        public void TestImportSubscriptionPublishSettingsSecondVersionOnlyProcess()
        {
            MockCommandRuntime mockCommandRuntime;
            ImportAzurePublishSettingsCommand cmdlet;
            mockCommandRuntime = new MockCommandRuntime();
            cmdlet = new ImportAzurePublishSettingsCommand();
            cmdlet.CommandRuntime = mockCommandRuntime;
            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);
        }
        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);
        }
        public void TestImportSubscriptionPublishSettingsOnlyMultipleTimesProcess()
        {
            MockCommandRuntime mockCommandRuntime;
            ImportAzurePublishSettingsCommand cmdlet;
            mockCommandRuntime = new MockCommandRuntime();
            cmdlet = new ImportAzurePublishSettingsCommand();
            cmdlet.CommandRuntime = mockCommandRuntime;
            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);
        }
        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();
        }