Esempio n. 1
0
        public void TestUpdateSubscriptions()
        {
            var globalComponents = GlobalComponents.CreateFromPublishSettings(GlobalPathInfo.GlobalSettingsDirectory, null, Data.ValidPublishSettings.First());

            var cmdletStub    = new CmdletStub();
            var subscriptions = cmdletStub.GetSubscriptions(Data.ValidSubscriptionsData[0]);

            var deleteSubscriptionKey = subscriptions.Keys.First();

            subscriptions.Remove(deleteSubscriptionKey);

            var newPath = Path.Combine(GlobalPathInfo.GlobalSettingsDirectory, "test.xml");

            cmdletStub.UpdateSubscriptions(subscriptions, newPath);

            var newSubscriptions = cmdletStub.GetSubscriptions(newPath);

            Assert.IsFalse(newSubscriptions.ContainsKey(deleteSubscriptionKey));

            globalComponents.DeleteGlobalComponents();
        }
Esempio n. 2
0
        public void TestGetSubscriptions()
        {
            var globalComponents = GlobalComponents.CreateFromPublishSettings(GlobalPathInfo.GlobalSettingsDirectory, null, Data.ValidPublishSettings.First());

            var cmdletStub    = new CmdletStub();
            var subscriptions = cmdletStub.GetSubscriptions(null);

            // All subscriptions from both the publish settings file and the subscriptions file were imported
            Assert.AreEqual(6, subscriptions.Count);

            // There's a single default subscription
            Assert.AreEqual("Windows Azure Sandbox 9-220", subscriptions.Values.Single(subscription => subscription.IsDefault).SubscriptionName);

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

            var cmdletStub = new CmdletStub();
            var subscriptions = cmdletStub.GetSubscriptions(null);

            // All subscriptions from both the publish settings file and the subscriptions file were imported
            Assert.AreEqual(6, subscriptions.Count);

            // There's a single default subscription
            Assert.AreEqual("Windows Azure Sandbox 9-220", subscriptions.Values.Single(subscription => subscription.IsDefault).SubscriptionName);

            globalSettingsManager.DeleteGlobalSettingsManager();
        }
        public void TestGetCurrentSubscription()
        {
            var globalSettingsManager = GlobalSettingsManager.CreateFromPublishSettings(GlobalPathInfo.GlobalSettingsDirectory, null, Data.ValidPublishSettings.First());

            var cmdletStub = new CmdletStub();
            var subscriptions = cmdletStub.GetSubscriptions(null);

            var currentSubscription = subscriptions.Values.First();
            cmdletStub.SetCurrentSubscription(currentSubscription.SubscriptionName, null);

            // Test
            var actualCurrentSubscription = cmdletStub.GetCurrentSubscription();
            Assert.AreEqual(currentSubscription.SubscriptionName, actualCurrentSubscription.SubscriptionName);
            Assert.AreEqual(currentSubscription.SubscriptionId, actualCurrentSubscription.SubscriptionId);

            globalSettingsManager.DeleteGlobalSettingsManager();
        }
Esempio n. 5
0
        public void TestGetCurrentSubscription()
        {
            var globalComponents = GlobalComponents.CreateFromPublishSettings(GlobalPathInfo.GlobalSettingsDirectory, null, Data.ValidPublishSettings.First());

            var cmdletStub    = new CmdletStub();
            var subscriptions = cmdletStub.GetSubscriptions(null);

            var currentSubscription = subscriptions.Values.First();

            cmdletStub.SetCurrentSubscription(currentSubscription.SubscriptionName, null);

            // Test
            var actualCurrentSubscription = cmdletStub.GetCurrentSubscription();

            Assert.AreEqual(currentSubscription.SubscriptionName, actualCurrentSubscription.SubscriptionName);
            Assert.AreEqual(currentSubscription.SubscriptionId, actualCurrentSubscription.SubscriptionId);

            globalComponents.DeleteGlobalComponents();
        }
Esempio n. 6
0
        public void TestSetDefaultSubscription()
        {
            var globalComponents = GlobalComponents.CreateFromPublishSettings(GlobalPathInfo.GlobalSettingsDirectory, null, Data.ValidPublishSettings.First());

            var newPath = Path.Combine(GlobalPathInfo.GlobalSettingsDirectory, "test.xml");

            File.Copy(Data.ValidSubscriptionsData[0], newPath, true);

            var cmdletStub    = new CmdletStub();
            var subscriptions = cmdletStub.GetSubscriptions(Data.ValidSubscriptionsData[0]);

            var newDefaultSubscription = subscriptions.Values.First(subscription => !subscription.IsDefault);

            cmdletStub.SetDefaultSubscription(newDefaultSubscription.SubscriptionName, newPath);

            // Test - reimport and make sure the current subscription after import is the correct one
            var subscriptionsManager = GlobalComponents.Load(GlobalPathInfo.GlobalSettingsDirectory, newPath).SubscriptionManager;
            var defaultSubscription  = subscriptionsManager.Subscriptions.Values.First(subscription => subscription.IsDefault);

            Assert.AreEqual(newDefaultSubscription.SubscriptionName, defaultSubscription.SubscriptionName);

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

            var newPath = Path.Combine(GlobalPathInfo.GlobalSettingsDirectory, "test.xml");
            File.Copy(Data.ValidSubscriptionsData[0], newPath, true);

            var cmdletStub = new CmdletStub();
            var subscriptions = cmdletStub.GetSubscriptions(Data.ValidSubscriptionsData[0]);

            var newDefaultSubscription = subscriptions.Values.First(subscription => !subscription.IsDefault);
            cmdletStub.SetDefaultSubscription(newDefaultSubscription.SubscriptionName, newPath);

            // Test - reimport and make sure the current subscription after import is the correct one
            var subscriptionsManager = GlobalSettingsManager.Load(GlobalPathInfo.GlobalSettingsDirectory, newPath).SubscriptionManager;
            var defaultSubscription = subscriptionsManager.Subscriptions.Values.First(subscription => subscription.IsDefault);
            Assert.AreEqual(newDefaultSubscription.SubscriptionName, defaultSubscription.SubscriptionName);

            globalSettingsManager.DeleteGlobalSettingsManager();
        }
        public void TestUpdateSubscriptions()
        {
            var globalSettingsManager = GlobalSettingsManager.CreateFromPublishSettings(GlobalPathInfo.GlobalSettingsDirectory, null, Data.ValidPublishSettings.First());

            var cmdletStub = new CmdletStub();
            var subscriptions = cmdletStub.GetSubscriptions(Data.ValidSubscriptionsData[0]);

            var deleteSubscriptionKey = subscriptions.Keys.First();
            subscriptions.Remove(deleteSubscriptionKey);

            var newPath = Path.Combine(GlobalPathInfo.GlobalSettingsDirectory, "test.xml");
            cmdletStub.UpdateSubscriptions(subscriptions, newPath);

            var newSubscriptions = cmdletStub.GetSubscriptions(newPath);
            Assert.IsFalse(newSubscriptions.ContainsKey(deleteSubscriptionKey));

            globalSettingsManager.DeleteGlobalSettingsManager();
        }