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


C# MockDataStore.WriteFile方法代码示例

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


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

示例1: ImportPublishSettingsAddsSecondCertificate

        public void ImportPublishSettingsAddsSecondCertificate()
        {
            MockDataStore dataStore = new MockDataStore();
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();
            var newSubscription = new AzureSubscription
            {
                Id = new Guid("f62b1e05-af8f-4203-8f97-421089adc053"),
                Name = "Microsoft Azure Sandbox 9-220",
                Environment = EnvironmentName.AzureCloud,
                Account = azureAccount.Id
            };
            azureAccount.SetProperty(AzureAccount.Property.Subscriptions, newSubscription.Id.ToString());
            client.AddOrSetAccount(azureAccount);
            client.AddOrSetSubscription(newSubscription);
            client.Profile.Save();

            client = new ProfileClient();

            dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings",
                Properties.Resources.ValidProfile);

            client.AddOrSetEnvironment(azureEnvironment);
            var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", azureEnvironment.Name);

            Assert.Equal(2, client.Profile.Accounts.Count());
            var certAccount = client.Profile.Accounts.Values.First(a => a.Type == AzureAccount.AccountType.Certificate);
            var userAccount = client.Profile.Accounts.Values.First(a => a.Type == AzureAccount.AccountType.User);

            Assert.True(subscriptions.All(s => s.Account == certAccount.Id));
            Assert.Equal(azureAccount.Id, client.Profile.Subscriptions.Values.First(s => s.Id == newSubscription.Id).Account);

            Assert.True(userAccount.GetPropertyAsArray(AzureAccount.Property.Subscriptions).Contains(newSubscription.Id.ToString()));
            Assert.True(certAccount.GetPropertyAsArray(AzureAccount.Property.Subscriptions).Contains(newSubscription.Id.ToString()));

            Assert.Equal(6, subscriptions.Count);
            Assert.Equal(6, client.Profile.Subscriptions.Count);
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:38,代码来源:ProfileClientTests.cs

示例2: ImportPublishSettingsUsesPassedInEnvironment

        public void ImportPublishSettingsUsesPassedInEnvironment()
        {
            MockDataStore dataStore = new MockDataStore();
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();
            client.AddOrSetAccount(azureAccount);
            client.AddOrSetEnvironment(azureEnvironment);
            client.AddOrSetSubscription(azureSubscription1);
            client.SetSubscriptionAsDefault(azureSubscription1.Name, azureAccount.Id);
            client.Profile.Save();

            client = new ProfileClient();

            dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings",
                Properties.Resources.ValidProfile3);

            client.AddOrSetEnvironment(azureEnvironment);
            var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", azureEnvironment.Name);

            Assert.True(subscriptions.All(s => s.Environment == azureEnvironment.Name));
            Assert.Equal(6, subscriptions.Count);
            Assert.Equal(7, client.Profile.Subscriptions.Count);
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:23,代码来源:ProfileClientTests.cs

示例3: ImportPublishSettingsUsesProperEnvironmentWithChinaManagementUrlOld

        public void ImportPublishSettingsUsesProperEnvironmentWithChinaManagementUrlOld()
        {
            MockDataStore dataStore = new MockDataStore();
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();

            dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings",
                Properties.Resources.ValidProfileChinaOld);

            client.AddOrSetEnvironment(azureEnvironment);
            var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", null);

            Assert.True(subscriptions.All(s => s.Environment == EnvironmentName.AzureChinaCloud));
            Assert.Equal(1, subscriptions.Count);
            Assert.Equal(1, client.Profile.Subscriptions.Count);
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:16,代码来源:ProfileClientTests.cs

示例4: ImportPublishSettingsUsesProperEnvironmentWithManagementUrl

        public void ImportPublishSettingsUsesProperEnvironmentWithManagementUrl()
        {
            MockDataStore dataStore = new MockDataStore();
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();
            client.AddOrSetAccount(azureAccount);
            azureEnvironment.Endpoints[AzureEnvironment.Endpoint.ServiceManagement] = "https://newmanagement.core.windows.net/";
            client.AddOrSetEnvironment(azureEnvironment);
            client.AddOrSetSubscription(azureSubscription1);
            client.SetSubscriptionAsDefault(azureSubscription1.Name, azureAccount.Id);
            client.Profile.Save();

            client = new ProfileClient();

            dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings",
                Properties.Resources.ValidProfile3);

            client.AddOrSetEnvironment(azureEnvironment);
            var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", null);

            Assert.True(subscriptions.All(s => s.Environment == azureEnvironment.Name));
            Assert.Equal(6, subscriptions.Count);
            Assert.Equal(7, client.Profile.Subscriptions.Count);
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:24,代码来源:ProfileClientTests.cs

示例5: ImportPublishSettingsLoadsAndReturnsSubscriptions

        public void ImportPublishSettingsLoadsAndReturnsSubscriptions()
        {
            MockDataStore dataStore = new MockDataStore();
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();

            dataStore.WriteFile("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings",
                Properties.Resources.ValidProfile);

            client.AddOrSetEnvironment(azureEnvironment);
            var subscriptions = client.ImportPublishSettings("ImportPublishSettingsLoadsAndReturnsSubscriptions.publishsettings", azureEnvironment.Name);
            var account = client.Profile.Accounts.Values.First();

            Assert.True(subscriptions.All(s => s.Account == account.Id));
            Assert.Equal(6, subscriptions.Count);
            Assert.Equal(6, client.Profile.Subscriptions.Count);
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:17,代码来源:ProfileClientTests.cs

示例6: LoadingProfileWorks

        public void LoadingProfileWorks()
        {
            string contents = @"{
  ""Environments"": {
    ""testCloud"": {
      ""Name"": ""testCloud"",
      ""OnPremise"": false,
      ""Endpoints"": {
        ""ActiveDirectory"": ""http://contoso.com""
      }
    }
  },
  ""Context"": {
    ""TokenCache"": ""AQIDBAUGCAkA"",
    ""Account"": {
      ""Id"": ""[email protected]"",
      ""Type"": 1,
      ""Properties"": {
        ""Tenants"": ""3c0ff8a7-e8bb-40e8-ae66-271343379af6""
      }
    },
    ""Subscription"": {
      ""Id"": ""00000000-0000-0000-0000-000000000000"",
      ""Name"": ""Contoso Test Subscription"",
      ""Environment"": ""testCloud"",
      ""Account"": ""[email protected]"",
      ""Properties"": {
        ""Tenants"": ""3c0ff8a7-e8bb-40e8-ae66-271343379af6""
      }
    },
    ""Environment"": {
      ""Name"": ""testCloud"",
      ""OnPremise"": false,
      ""Endpoints"": {
        ""ActiveDirectory"": ""http://contoso.com""
      }
    },
    ""Tenant"": {
      ""Id"": ""3c0ff8a7-e8bb-40e8-ae66-271343379af6"",
      ""Domain"": ""contoso.com""
    }
  }
}";
            var path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AzureSession.ProfileFile);
            var dataStore = new MockDataStore();
            AzureSession.DataStore = dataStore;
            dataStore.WriteFile(path, contents);
            var profile = new AzureRMProfile(path);
            Assert.Equal(4, profile.Environments.Count);
            Assert.Equal("3c0ff8a7-e8bb-40e8-ae66-271343379af6", profile.Context.Tenant.Id.ToString());
            Assert.Equal("contoso.com", profile.Context.Tenant.Domain);
            Assert.Equal("00000000-0000-0000-0000-000000000000", profile.Context.Subscription.Id.ToString());
            Assert.Equal("testCloud", profile.Context.Environment.Name);
            Assert.Equal("[email protected]", profile.Context.Account.Id);
            Assert.Equal(new byte[] { 1, 2, 3, 4, 5, 6, 8, 9, 0 }, profile.Context.TokenCache);
            Assert.Equal(path, profile.ProfilePath);
        }
开发者ID:rohmano,项目名称:azure-powershell,代码行数:57,代码来源:AzureRMProfileTests.cs


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