コード例 #1
0
        public void ImportingSchema2PublishSettingsAddsSubscriptionsToProfile()
        {
            var store = new Mock<IProfileStore>();
            var profile = new WindowsAzureProfile(store.Object);
            XDocument expected;

            using (Stream s = GetPublishSettingsStream("ValidProfile2.PublishSettings"))
            {
                expected = ReadExpected(s);
                s.Seek(0, SeekOrigin.Begin);
                profile.ImportPublishSettings(s);
            }

            Assert.AreEqual(expected.Descendants("Subscription").Count(), profile.Subscriptions.Count);

            foreach (var id in expected.Descendants("Subscription").Select(s => s.Attribute("Id").Value))
            {
                Assert.IsTrue(profile.Subscriptions.Any(s => s.SubscriptionId == id));
            }

            foreach (var name in expected.Descendants("Subscription").Select(s => s.Attribute("Name").Value))
            {
                Assert.IsTrue(profile.Subscriptions.Any(s => s.SubscriptionName == name));
            }

            foreach (var uri in
                expected.Descendants("Subscription")
                .Select(s => new Uri(s.Attribute("ServiceManagementUrl").Value)))
            {
                Assert.IsTrue(profile.Subscriptions.Any(s => s.ServiceEndpoint == uri));
            }
        }
コード例 #2
0
        public void ImportingSchema2PublishSettingsAddsSubscriptionsToProfile()
        {
            var       store   = new Mock <IProfileStore>();
            var       profile = new WindowsAzureProfile(store.Object);
            XDocument expected;

            using (Stream s = GetPublishSettingsStream("ValidProfile2.PublishSettings"))
            {
                expected = ReadExpected(s);
                s.Seek(0, SeekOrigin.Begin);
                profile.ImportPublishSettings(s);
            }

            Assert.AreEqual(expected.Descendants("Subscription").Count(), profile.Subscriptions.Count);

            foreach (var id in expected.Descendants("Subscription").Select(s => s.Attribute("Id").Value))
            {
                Assert.IsTrue(profile.Subscriptions.Any(s => s.SubscriptionId == id));
            }

            foreach (var name in expected.Descendants("Subscription").Select(s => s.Attribute("Name").Value))
            {
                Assert.IsTrue(profile.Subscriptions.Any(s => s.SubscriptionName == name));
            }

            foreach (var uri in
                     expected.Descendants("Subscription")
                     .Select(s => new Uri(s.Attribute("ServiceManagementUrl").Value)))
            {
                Assert.IsTrue(profile.Subscriptions.Any(s => s.ServiceEndpoint == uri));
            }
        }
コード例 #3
0
 public void Setup()
 {
     profile = new WindowsAzureProfile(new Mock <IProfileStore>().Object);
     using (var s = GetPublishSettingsStream("ValidProfile.PublishSettings"))
     {
         profile.ImportPublishSettings(s);
     }
 }
コード例 #4
0
 public void Setup()
 {
     profile = new WindowsAzureProfile(new Mock<IProfileStore>().Object);
     using (var s = GetPublishSettingsStream("ValidProfile.PublishSettings"))
     {
         profile.ImportPublishSettings(s);
     }
 }
コード例 #5
0
        public void Setup()
        {
            profile = new WindowsAzureProfile(new Mock <IProfileStore>().Object);
            profile.ImportPublishSettings(Data.ValidPublishSettings.First());

            mockCommandRuntime = new MockCommandRuntime();

            cmdlet = new GetAzureSubscriptionCommand
            {
                Profile        = profile,
                CommandRuntime = mockCommandRuntime
            };
        }
コード例 #6
0
        public void Setup()
        {
            profile = new WindowsAzureProfile(new Mock<IProfileStore>().Object);
            profile.ImportPublishSettings(Data.ValidPublishSettings.First());

            mockCommandRuntime = new MockCommandRuntime();

            cmdlet = new GetAzureSubscriptionCommand
            {
                Profile = profile,
                CommandRuntime = mockCommandRuntime
            };
        }
コード例 #7
0
        /// <summary>
        /// Create a temporary Azure SDK directory to simulate global files.
        /// </summary>
        /// <param name="publishSettingsPath">
        /// Path to the publish settings.
        /// </param>
        /// <returns>The path to the temporary Azure SDK directory.</returns>
        public string CreateAzureSdkDirectoryAndImportPublishSettings(string publishSettingsPath)
        {
            Debug.Assert(!string.IsNullOrEmpty(publishSettingsPath));
            Debug.Assert(File.Exists(publishSettingsPath));
            Debug.Assert(string.IsNullOrEmpty(AzureSdkPath));

            AzureSdkPath = CreateDirectory("AzureSdk");
            var profile = new WindowsAzureProfile(new PowershellProfileStore(AzureSdkPath, "WindowsAzureProfile.xml"));

            profile.ImportPublishSettings(publishSettingsPath);
            WindowsAzureProfile.Instance = profile;

            GlobalPathInfo.GlobalSettingsDirectory = AzureSdkPath;

            return(AzureSdkPath);
        }
コード例 #8
0
        public void ImportingSchema1PublishSettingsAddsSubscriptionsToProfile()
        {
            var       store   = new Mock <IProfileStore>();
            var       profile = new WindowsAzureProfile(store.Object);
            XDocument expected;

            using (Stream s = GetPublishSettingsStream("Azure.publishsettings"))
            {
                expected = ReadExpected(s);
                s.Seek(0, SeekOrigin.Begin);
                profile.ImportPublishSettings(s);
            }

            // This sample file has two subscriptions with the same ID.
            // When added to the profile the duplication is stripped out.
            Assert.AreEqual(expected.Descendants("Subscription").Count() - 1,
                            profile.Subscriptions.Count);

            foreach (var id in expected.Descendants("Subscription").Select(s => s.Attribute("Id").Value))
            {
                Assert.IsTrue(profile.Subscriptions.Any(s => s.SubscriptionId == id));
            }

            foreach (var name in expected.Descendants("Subscription").Skip(1).Select(s => s.Attribute("Name").Value))
            {
                Assert.IsTrue(profile.Subscriptions.Any(s => s.SubscriptionName == name));
            }

            Uri expectedManagementUri =
                expected.Descendants("PublishProfile").Select(p => new Uri(p.Attribute("Url").Value)).First();

            foreach (var s in profile.Subscriptions)
            {
                Assert.AreEqual(expectedManagementUri, s.ServiceEndpoint);
                Assert.IsNotNull(s.SqlDatabaseDnsSuffix);
            }

            store.Verify(s => s.Save(It.IsAny <ProfileData>()), Times.Once);
        }
コード例 #9
0
        public void SavingWritesProfileDataToStore()
        {
            var         storeMock = new Mock <IProfileStore>();
            ProfileData savedData = null;

            storeMock.Setup(s => s.Save(It.IsAny <ProfileData>()))
            .Callback((ProfileData data) => { savedData = data; });

            var profile   = new WindowsAzureProfile(storeMock.Object);
            var sourceEnv = testProfileData.Environments.First();

            profile.AddEnvironment(new WindowsAzureEnvironment
            {
                ManagementPortalUrl = sourceEnv.ManagementPortalUrl,
                Name = sourceEnv.Name,
                PublishSettingsFileUrl                   = sourceEnv.PublishSettingsFileUrl,
                ServiceEndpoint                          = sourceEnv.ServiceEndpoint,
                ActiveDirectoryEndpoint                  = sourceEnv.AdTenantUrl,
                ActiveDirectoryCommonTenantId            = sourceEnv.CommonTenantId,
                StorageEndpointSuffix                    = sourceEnv.StorageEndpointSuffix,
                GalleryEndpoint                          = sourceEnv.GalleryEndpoint,
                ActiveDirectoryServiceEndpointResourceId = sourceEnv.ActiveDirectoryServiceEndpointResourceId,
                SqlDatabaseDnsSuffix                     = sourceEnv.SqlDatabaseDnsSuffix,
            });

            var locator = typeof(ResourceLocator);

            profile.ImportPublishSettings(locator.Assembly
                                          .GetManifestResourceStream(locator, "Azure.publishsettings"));

            // Should save twice, one for environment, one for subscription import
            storeMock.Verify(s => s.Save(It.IsAny <ProfileData>()), Times.Exactly(2));

            // Validate that the saved data looks right
            Assert.AreEqual(1, savedData.Environments.Count());
            Assert.AreEqual(EnvironmentName.AzureCloud, savedData.DefaultEnvironmentName);
            AssertEqual(sourceEnv, savedData.Environments.First());
            Assert.AreEqual(3, savedData.Subscriptions.Count());
        }
コード例 #10
0
        public void ImportingSchema1PublishSettingsAddsSubscriptionsToProfile()
        {
            var store = new Mock<IProfileStore>();
            var profile = new WindowsAzureProfile(store.Object);
            XDocument expected;

            using (Stream s = GetPublishSettingsStream("Azure.publishsettings"))
            {
                expected = ReadExpected(s);
                s.Seek(0, SeekOrigin.Begin);
                profile.ImportPublishSettings(s);
            }

            // This sample file has two subscriptions with the same ID.
            // When added to the profile the duplication is stripped out.
            Assert.AreEqual(expected.Descendants("Subscription").Count() - 1,
                profile.Subscriptions.Count);

            foreach (var id in expected.Descendants("Subscription").Select(s => s.Attribute("Id").Value))
            {
                Assert.IsTrue(profile.Subscriptions.Any(s => s.SubscriptionId == id));
            }

            foreach(var name in expected.Descendants("Subscription").Skip(1).Select(s => s.Attribute("Name").Value))
            {
                Assert.IsTrue(profile.Subscriptions.Any(s => s.SubscriptionName == name));
            }

            Uri expectedManagementUri =
                expected.Descendants("PublishProfile").Select(p => new Uri(p.Attribute("Url").Value)).First();
            foreach (var s in profile.Subscriptions)
            {
                Assert.AreEqual(expectedManagementUri, s.ServiceEndpoint);
                Assert.IsNotNull(s.SqlDatabaseDnsSuffix);
            }

            store.Verify(s => s.Save(It.IsAny<ProfileData>()), Times.Once);
        }
コード例 #11
0
        /// <summary>
        /// Create a temporary Azure SDK directory to simulate global files.
        /// </summary>
        /// <param name="publishSettingsPath">
        /// Path to the publish settings.
        /// </param>
        /// <returns>The path to the temporary Azure SDK directory.</returns>
        public string CreateAzureSdkDirectoryAndImportPublishSettings(string publishSettingsPath)
        {
            Debug.Assert(!string.IsNullOrEmpty(publishSettingsPath));
            Debug.Assert(File.Exists(publishSettingsPath));
            Debug.Assert(string.IsNullOrEmpty(AzureSdkPath));

            AzureSdkPath = CreateDirectory("AzureSdk");
            var profile = new WindowsAzureProfile(new PowershellProfileStore(AzureSdkPath, "WindowsAzureProfile.xml"));
            profile.ImportPublishSettings(publishSettingsPath);
            WindowsAzureProfile.Instance = profile;

            GlobalPathInfo.GlobalSettingsDirectory = AzureSdkPath;

            return AzureSdkPath;
        }