public void GlobalComponentsCreateNew()
        {
            foreach (string fileName in Data.ValidPublishSettings)
            {
                // Prepare
                GlobalComponents globalComponents        = GlobalComponents.CreateFromPublishSettings(Data.AzureAppDir, null, fileName);
                PublishData      expectedPublishSettings = General.DeserializeXmlFile <PublishData>(fileName);

                // Assert
                AzureAssert.AreEqualGlobalComponents(new GlobalPathInfo(Data.AzureAppDir), expectedPublishSettings, globalComponents);

                // Clean
                globalComponents.DeleteGlobalComponents();
            }
        }
        public void GlobalComponentsLoadExisting()
        {
            for (var i = 0; i < Data.ValidPublishSettings.Count; i++)
            {
                var publishSettingsFile = Data.ValidPublishSettings[i];

                // Prepare
                new ImportAzurePublishSettingsCommand().ImportSubscriptionProcess(publishSettingsFile, null);
                GlobalComponents globalComponents        = GlobalComponents.Load(Data.AzureAppDir);
                PublishData      actualPublishSettings   = General.DeserializeXmlFile <PublishData>(Path.Combine(Data.AzureAppDir, Resources.PublishSettingsFileName));
                PublishData      expectedPublishSettings = General.DeserializeXmlFile <PublishData>(publishSettingsFile);

                // Assert
                AzureAssert.AreEqualGlobalComponents(new GlobalPathInfo(Data.AzureAppDir), expectedPublishSettings, globalComponents);

                // Clean
                globalComponents.DeleteGlobalComponents();
            }
        }
        public void GlobalComponentsLoadIgnoresPublishExisting()
        {
            var publishSettingsFile        = Data.ValidPublishSettings.First();
            var subscriptionDataFile       = Data.ValidSubscriptionsData.First();
            var outputSubscriptionDataFile = Path.Combine(Directory.GetParent(subscriptionDataFile).FullName, "outputNoPublish.xml");

            File.Copy(subscriptionDataFile, outputSubscriptionDataFile);

            // Create with both an existing ouput subscription data file and the publish settings file
            GlobalComponents globalComponents = GlobalComponents.CreateFromPublishSettings(Data.AzureAppDir, outputSubscriptionDataFile, publishSettingsFile);

            Assert.AreEqual(5, globalComponents.Subscriptions.Count);

            // Remove one of the subscriptions from the publish settings file
            globalComponents.Subscriptions.Remove("TestSubscription1");
            globalComponents.SaveSubscriptions();

            // Load and make sure the subscription is still gone although it still is in the publish settings file
            globalComponents = GlobalComponents.Load(Data.AzureAppDir, outputSubscriptionDataFile);
            Assert.AreEqual(4, globalComponents.Subscriptions.Count);

            // Clean
            globalComponents.DeleteGlobalComponents();
        }