当前位置: 首页>>代码示例>>C#>>正文


C# ProfileClient.GetSubscription方法代码示例

本文整理汇总了C#中ProfileClient.GetSubscription方法的典型用法代码示例。如果您正苦于以下问题:C# ProfileClient.GetSubscription方法的具体用法?C# ProfileClient.GetSubscription怎么用?C# ProfileClient.GetSubscription使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ProfileClient的用法示例。


在下文中一共展示了ProfileClient.GetSubscription方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: GetAzureSubscriptionByIdChecksAndReturnsOnlyLocal

        public void GetAzureSubscriptionByIdChecksAndReturnsOnlyLocal()
        {
            SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1, csmSubscription1withDuplicateId }.ToList());
            MockDataStore dataStore = new MockDataStore();
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();
            client.AddOrSetAccount(azureAccount);
            PowerShellUtilities.GetCurrentModeOverride = () => AzureModule.AzureResourceManager;
            client.AddOrSetEnvironment(azureEnvironment);
            client.AddOrSetSubscription(azureSubscription1);
            client.AddOrSetSubscription(azureSubscription2);

            var subscriptions = client.GetSubscription(azureSubscription1.Id);

            Assert.Equal(azureSubscription1.Id, subscriptions.Id);
            Assert.Throws<ArgumentException>(() => client.GetSubscription(new Guid()));
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:17,代码来源:ProfileClientTests.cs

示例2: GetAzureSubscriptionByIdChecksAndReturnsOnlyLocal

        public void GetAzureSubscriptionByIdChecksAndReturnsOnlyLocal()
        {
            SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1, csmSubscription1withDuplicateId }.ToList());
            MemoryDataStore dataStore = new MemoryDataStore();
            AzureSession.DataStore = dataStore;
            currentProfile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            ProfileClient client = new ProfileClient(currentProfile);
            client.AddOrSetAccount(azureAccount);
            client.AddOrSetEnvironment(azureEnvironment);
            client.AddOrSetSubscription(azureSubscription1);
            client.AddOrSetSubscription(azureSubscription2);

            var subscriptions = client.GetSubscription(azureSubscription1.Id);

            Assert.Equal(azureSubscription1.Id, subscriptions.Id);
            Assert.Throws<ArgumentException>(() => client.GetSubscription(new Guid()));
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:17,代码来源:ProfileClientTests.cs

示例3: ImportPublishSettingsWorksForCustomProfile

        public void ImportPublishSettingsWorksForCustomProfile()
        {
            ImportAzurePublishSettingsCommand cmdlt = new ImportAzurePublishSettingsCommand();
            var oldAzureDataStore = AzureSession.DataStore;
            AzureSession.DataStore = new MemoryDataStore();
            // Setup
            AzureSession.DataStore.WriteFile("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings",
                Commands.Common.Test.Properties.Resources.ValidProfileChina);
            var oldProfile = new AzureProfile();
            AzurePSCmdlet.CurrentProfile = oldProfile;
            var profile = new AzureProfile();
            ProfileClient client = new ProfileClient(profile);
            var oldDataStore = FileUtilities.DataStore;
            FileUtilities.DataStore = AzureSession.DataStore;
            var expectedEnv = "AzureCloud";
            var expected = client.ImportPublishSettings("ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings", expectedEnv);
            AzurePSCmdlet.CurrentProfile = new AzureProfile();
            cmdlt.Profile = profile;
            cmdlt.CommandRuntime = commandRuntimeMock;
            cmdlt.ProfileClient = new ProfileClient(new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile)));
            cmdlt.PublishSettingsFile = "ImportPublishSettingsFileSelectsCorrectEnvironment.publishsettings";
            cmdlt.Environment = expectedEnv;

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

                // Verify
                foreach (var subscription in expected)
                {
                    Assert.Equal(client.GetSubscription(subscription.Id).Environment, expectedEnv);
                }
                Assert.Equal(1, commandRuntimeMock.OutputPipeline.Count);
                Assert.Equal(oldProfile.Subscriptions.Count, 0);
                Assert.Equal(oldProfile.Accounts.Count, 0);
            }
            finally
            {
                // Cleanup
                FileUtilities.DataStore = oldDataStore;
                AzureSession.DataStore = oldAzureDataStore;
            }
        }
开发者ID:pelagos,项目名称:azure-powershell,代码行数:46,代码来源:ProfileCmdltsTests.cs

示例4: GetAzureSubscriptionByNameChecksAndReturnsOnlyLocal

        public void GetAzureSubscriptionByNameChecksAndReturnsOnlyLocal()
        {
            SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1, csmSubscription1withDuplicateId }.ToList());
            MockDataStore dataStore = new MockDataStore();
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();
            client.AddOrSetAccount(azureAccount);
            client.AddOrSetEnvironment(azureEnvironment);
            client.AddOrSetSubscription(azureSubscription1);
            client.AddOrSetSubscription(azureSubscription2);

            var subscriptions = client.GetSubscription(azureSubscription1.Name);

            Assert.Equal(azureSubscription1.Id, subscriptions.Id);
            Assert.Throws<ArgumentException>(() => client.GetSubscription(new Guid()));
        }
开发者ID:khoatle,项目名称:azure-powershell,代码行数:16,代码来源:ProfileClientTests.cs


注:本文中的ProfileClient.GetSubscription方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。