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


C# Models.MemoryDataStore类代码示例

本文整理汇总了C#中Microsoft.Azure.Common.Authentication.Models.MemoryDataStore的典型用法代码示例。如果您正苦于以下问题:C# MemoryDataStore类的具体用法?C# MemoryDataStore怎么用?C# MemoryDataStore使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


MemoryDataStore类属于Microsoft.Azure.Common.Authentication.Models命名空间,在下文中一共展示了MemoryDataStore类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ProfileCmdletTests

 public ProfileCmdletTests()
 {
     dataStore = new MemoryDataStore();
     AzureSession.DataStore = dataStore;
     commandRuntimeMock = new MockCommandRuntime();
     AzureSession.AuthenticationFactory = new MockTokenAuthenticationFactory();
 }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:7,代码来源:ProfileCmdletTests.cs

示例2: TenantCmdletTests

 public TenantCmdletTests()
 {
     dataStore = new MemoryDataStore();
     AzureSession.DataStore = dataStore;
     commandRuntimeMock = new MockCommandRuntime();
     AzureRmProfileProvider.Instance.Profile = new AzureRMProfile();
 }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:7,代码来源:TenantCmdletTests.cs

示例3: NewProfileFromCertificateWithNullsThrowsArgumentNullException

 public void NewProfileFromCertificateWithNullsThrowsArgumentNullException()
 {
     MemoryDataStore dataStore = new MemoryDataStore();
     AzureSession.DataStore = dataStore;
     AzureProfile newProfile = new AzureProfile();
     ProfileClient client1 = new ProfileClient(newProfile);
     Assert.Throws<ArgumentNullException>(() =>
         client1.InitializeProfile(null, Guid.NewGuid(), new X509Certificate2(), "foo"));
     Assert.Throws<ArgumentNullException>(() =>
         client1.InitializeProfile(AzureEnvironment.PublicEnvironments["AzureCloud"], Guid.NewGuid(), null, "foo"));
 }
开发者ID:safeermohammed,项目名称:azure-sdk-for-net,代码行数:11,代码来源:ProfileClientTests.cs

示例4: ProfileMigratesOldData

        public void ProfileMigratesOldData()
        {
            MemoryDataStore dataStore = new MemoryDataStore();
            dataStore.VirtualStore[oldProfileDataPath] = oldProfileData;
            AzureSession.DataStore = dataStore;
            currentProfile = new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            ProfileClient client = new ProfileClient(currentProfile);

            Assert.False(dataStore.FileExists(oldProfileDataPath));
            Assert.True(dataStore.FileExists(newProfileDataPath));
        }
开发者ID:safeermohammed,项目名称:azure-sdk-for-net,代码行数:11,代码来源:ProfileClientTests.cs

示例5: AzureSession

 static AzureSession()
 {
     ClientFactory = new ClientFactory();
     AuthenticationFactory = new AuthenticationFactory();
     DataStore = new MemoryDataStore();
     TokenCache = new TokenCache();
     OldProfileFile = "WindowsAzureProfile.xml";
     OldProfileFileBackup = "WindowsAzureProfile.xml.bak";
     ProfileDirectory = Path.Combine(
         Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),
         Resources.AzureDirectoryName); ;
     ProfileFile = "AzureProfile.json";
     TokenCacheFile = "TokenCache.dat";
 }
开发者ID:theadriangreen,项目名称:azure-sdk-for-net,代码行数:14,代码来源:AzureSession.cs

示例6: EnvironmentSetupHelper

        public EnvironmentSetupHelper()
        {
            var datastore = new MemoryDataStore();
            AzureSession.DataStore = datastore;
            var profile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            var rmprofile = new AzureRMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            rmprofile.Environments.Add("foo", AzureEnvironment.PublicEnvironments.Values.FirstOrDefault());
            rmprofile.Context = new AzureContext(new AzureSubscription(), new AzureAccount(), rmprofile.Environments["foo"], new AzureTenant());
            rmprofile.Context.Subscription.Environment = "foo";
            if (AzureRmProfileProvider.Instance.Profile == null)
            {
                AzureRmProfileProvider.Instance.Profile = rmprofile;            }

            AzureSession.DataStore = datastore;            ProfileClient = new ProfileClient(profile);

            // Ignore SSL errors
            System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => true;

            // Set RunningMocked
            TestMockSupport.RunningMocked = HttpMockServer.GetCurrentMode() == HttpRecorderMode.Playback;
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:21,代码来源:EnvironmentSetupHelper.cs

示例7: EnvironmentSetupHelper

        public EnvironmentSetupHelper()
        {
            var datastore = new MemoryDataStore();
            AzureSession.DataStore = datastore;
            var profile = new AzureSMProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            AzureSMCmdlet.CurrentProfile = profile;
            AzureSession.DataStore = datastore;
            ProfileClient = new ProfileClient(profile);

            // Ignore SSL errors
            System.Net.ServicePointManager.ServerCertificateValidationCallback += (se, cert, chain, sslerror) => true;

            // Set RunningMocked
            if (HttpMockServer.GetCurrentMode() == HttpRecorderMode.Playback)
            {
                TestMockSupport.RunningMocked = true;
            }
            else
            {
                TestMockSupport.RunningMocked = false;
            }
        }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:22,代码来源:EnvironmentSetupHelper.cs

示例8: AddOrSetAzureSubscriptionUpdatesInMemory

        public void AddOrSetAzureSubscriptionUpdatesInMemory()
        {
            MemoryDataStore dataStore = new MemoryDataStore();
            AzureSession.DataStore = dataStore;
            ProfileClient client = new ProfileClient(currentProfile);

            client.AddOrSetAccount(azureAccount);
            client.AddOrSetEnvironment(azureEnvironment);
            client.AddOrSetSubscription(azureSubscription1);
            currentProfile.DefaultSubscription = azureSubscription1;
            azureSubscription1.Properties[AzureSubscription.Property.StorageAccount] = "testAccount";
            Assert.Equal(azureSubscription1.Id, currentProfile.Context.Subscription.Id);
            Assert.Equal(azureSubscription1.Properties[AzureSubscription.Property.StorageAccount],
                currentProfile.Context.Subscription.Properties[AzureSubscription.Property.StorageAccount]);

            var newSubscription = new AzureSubscription
            {
                Id = azureSubscription1.Id,
                Environment = azureSubscription1.Environment,
                Account = azureSubscription1.Account,
                Name = azureSubscription1.Name
            };
            newSubscription.Properties[AzureSubscription.Property.StorageAccount] = "testAccount1";

            client.AddOrSetSubscription(newSubscription);
            var newSubscriptionFromProfile = client.Profile.Subscriptions[newSubscription.Id];

            Assert.Equal(newSubscription.Id, currentProfile.Context.Subscription.Id);
            Assert.Equal(newSubscription.Id, newSubscriptionFromProfile.Id);
            Assert.Equal(newSubscription.Properties[AzureSubscription.Property.StorageAccount],
                currentProfile.Context.Subscription.Properties[AzureSubscription.Property.StorageAccount]);
            Assert.Equal(newSubscription.Properties[AzureSubscription.Property.StorageAccount],
                newSubscriptionFromProfile.Properties[AzureSubscription.Property.StorageAccount]);
        }
开发者ID:safeermohammed,项目名称:azure-sdk-for-net,代码行数:34,代码来源:ProfileClientTests.cs

示例9: RemoveAzureSubscriptionChecksAndRemoves

        public void RemoveAzureSubscriptionChecksAndRemoves()
        {
            MemoryDataStore dataStore = new MemoryDataStore();
            AzureSession.DataStore = dataStore;
            currentProfile = new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            ProfileClient client = new ProfileClient(currentProfile);

            client.Profile.Accounts[azureAccount.Id] = azureAccount;
            client.AddOrSetEnvironment(azureEnvironment);
            client.AddOrSetSubscription(azureSubscription1);
            client.SetSubscriptionAsDefault(azureSubscription1.Name, azureSubscription1.Account);

            Assert.Equal(1, client.Profile.Subscriptions.Count);

            List<string> log = new List<string>();
            client.WarningLog = log.Add;

            var subscription = client.RemoveSubscription(azureSubscription1.Name);

            Assert.Equal(0, client.Profile.Subscriptions.Count);
            Assert.Equal(azureSubscription1.Name, subscription.Name);
            Assert.Equal(1, log.Count);
            Assert.Equal(
                "The default subscription is being removed. Use Select-AzureSubscription -Default <subscriptionName> to select a new default subscription.",
                log[0]);
            Assert.Throws<ArgumentException>(() => client.RemoveSubscription("bad"));
            Assert.Throws<ArgumentNullException>(() => client.RemoveSubscription(null));
        }
开发者ID:safeermohammed,项目名称:azure-sdk-for-net,代码行数:28,代码来源:ProfileClientTests.cs

示例10: RemoveAzureAccountRemovesDefaultAccountFromSubscription

        public void RemoveAzureAccountRemovesDefaultAccountFromSubscription()
        {
            MemoryDataStore dataStore = new MemoryDataStore();
            AzureSession.DataStore = dataStore;
            currentProfile = new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            ProfileClient client = new ProfileClient(currentProfile);
            client.Profile.Subscriptions[azureSubscription1.Id] = azureSubscription1;
            client.Profile.Subscriptions[azureSubscription2.Id] = azureSubscription2;
            client.Profile.Accounts[azureAccount.Id] = azureAccount;
            azureSubscription3withoutUser.Account = "test2";
            client.Profile.Accounts["test2"] = new AzureAccount
            {
                Id = "test2",
                Type = AzureAccount.AccountType.User,
                Properties = new Dictionary<AzureAccount.Property, string>
                {
                    {AzureAccount.Property.Subscriptions, azureSubscription1.Id.ToString()}
                }
            };
            client.Profile.Subscriptions[azureSubscription1.Id].Account = azureAccount.Id;
            client.Profile.Environments[azureEnvironment.Name] = azureEnvironment;

            var account = client.RemoveAccount(azureAccount.Id);

            Assert.Equal("test2", client.Profile.Subscriptions[azureSubscription1.Id].Account);
        }
开发者ID:safeermohammed,项目名称:azure-sdk-for-net,代码行数:26,代码来源:ProfileClientTests.cs

示例11: NewProfileFromCertificateReturnsProfile

        public void NewProfileFromCertificateReturnsProfile()
        {
            MemoryDataStore dataStore = new MemoryDataStore();
            AzureSession.DataStore = dataStore;
            AzureProfile newProfile = new AzureProfile();
            ProfileClient client1 = new ProfileClient(newProfile);
            var subscriptionId = Guid.NewGuid();
            var certificate = new X509Certificate2(Convert.FromBase64String(dummyCertificate));

            client1.InitializeProfile(AzureEnvironment.PublicEnvironments["AzureCloud"],
                subscriptionId, certificate, null);

            Assert.Equal("AzureCloud", newProfile.DefaultSubscription.Environment);
            Assert.Equal(subscriptionId, newProfile.DefaultSubscription.Id);
            Assert.Equal(certificate.Thumbprint, newProfile.DefaultSubscription.Account);
            Assert.False(newProfile.DefaultSubscription.Properties.ContainsKey(AzureSubscription.Property.StorageAccount));
        }
开发者ID:safeermohammed,项目名称:azure-sdk-for-net,代码行数:17,代码来源:ProfileClientTests.cs

示例12: GetAzureAccountWithoutEnvironmentReturnsAccount

        public void GetAzureAccountWithoutEnvironmentReturnsAccount()
        {
            MemoryDataStore dataStore = new MemoryDataStore();
            AzureSession.DataStore = dataStore;
            currentProfile = new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            ProfileClient client = new ProfileClient(currentProfile);
            client.Profile.Subscriptions[azureSubscription1.Id] = azureSubscription1;
            client.Profile.Subscriptions[azureSubscription2.Id] = azureSubscription2;
            client.Profile.Subscriptions[azureSubscription3withoutUser.Id] = azureSubscription3withoutUser;
            client.Profile.Accounts[azureAccount.Id] = azureAccount;
            client.Profile.Environments[azureEnvironment.Name] = azureEnvironment;

            var account = client.ListAccounts("test").ToList();

            Assert.Equal(1, account.Count);
            Assert.Equal("test", account[0].Id);
            Assert.Equal(2, account[0].GetSubscriptions(client.Profile).Count);
            Assert.True(account[0].GetSubscriptions(client.Profile).Any(s => s.Id == azureSubscription1.Id));
            Assert.True(account[0].GetSubscriptions(client.Profile).Any(s => s.Id == azureSubscription2.Id));
        }
开发者ID:safeermohammed,项目名称:azure-sdk-for-net,代码行数:20,代码来源:ProfileClientTests.cs

示例13: EnvironmentCmdletTests

 public EnvironmentCmdletTests()
 {
     dataStore = new MemoryDataStore();
     AzureSession.DataStore = dataStore;
 }
开发者ID:docschmidt,项目名称:azure-powershell,代码行数:5,代码来源:EnvironmentCmdletTests.cs

示例14: RemoveAzureEnvironmentDoesNotRemoveEnvironmentSubscriptionsAndAccountsForAzureCloudOrChinaCloud

        public void RemoveAzureEnvironmentDoesNotRemoveEnvironmentSubscriptionsAndAccountsForAzureCloudOrChinaCloud()
        {
            MemoryDataStore dataStore = new MemoryDataStore();
            AzureSession.DataStore = dataStore;
            currentProfile = new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            ProfileClient client = new ProfileClient(currentProfile);

            client.Profile.Accounts[azureAccount.Id] = azureAccount;
            azureSubscription1.Environment = EnvironmentName.AzureCloud;
            azureSubscription2.Environment = EnvironmentName.AzureChinaCloud;
            client.Profile.Subscriptions[azureSubscription1.Id] = azureSubscription1;
            client.Profile.Subscriptions[azureSubscription2.Id] = azureSubscription2;

            Assert.Equal(1, client.Profile.Subscriptions.Values.Count(s => s.Environment == EnvironmentName.AzureCloud));
            Assert.Equal(1, client.Profile.Subscriptions.Values.Count(s => s.Environment == EnvironmentName.AzureChinaCloud));
            Assert.Equal(2, client.Profile.Environments.Count);
            Assert.Equal(1, client.Profile.Accounts.Count);

            Assert.Throws<ArgumentException>(() => client.RemoveEnvironment(EnvironmentName.AzureCloud));
            Assert.Throws<ArgumentException>(() => client.RemoveEnvironment(EnvironmentName.AzureChinaCloud));

            Assert.Equal(1, client.Profile.Subscriptions.Values.Count(s => s.Environment == EnvironmentName.AzureCloud));
            Assert.Equal(1, client.Profile.Subscriptions.Values.Count(s => s.Environment == EnvironmentName.AzureChinaCloud));
            Assert.Equal(2, client.Profile.Environments.Count);
            Assert.Equal(1, client.Profile.Accounts.Count);
        }
开发者ID:safeermohammed,项目名称:azure-sdk-for-net,代码行数:26,代码来源:ProfileClientTests.cs

示例15: GetAzureAccountReturnsAllAccountsWithNullUser

        public void GetAzureAccountReturnsAllAccountsWithNullUser()
        {
            MemoryDataStore dataStore = new MemoryDataStore();
            AzureSession.DataStore = dataStore;
            currentProfile = new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            ProfileClient client = new ProfileClient(currentProfile);
            client.Profile.Subscriptions[azureSubscription1.Id] = azureSubscription1;
            client.Profile.Subscriptions[azureSubscription2.Id] = azureSubscription2;
            client.Profile.Accounts[azureAccount.Id] = azureAccount;
            azureSubscription3withoutUser.Account = "test2";
            client.Profile.Accounts["test2"] = new AzureAccount
            {
                Id = "test2",
                Type = AzureAccount.AccountType.User,
                Properties = new Dictionary<AzureAccount.Property, string>
                {
                    {AzureAccount.Property.Subscriptions, azureSubscription3withoutUser.Id.ToString()}
                }
            };
            client.Profile.Subscriptions[azureSubscription3withoutUser.Id] = azureSubscription3withoutUser;
            client.Profile.Environments[azureEnvironment.Name] = azureEnvironment;

            var account = client.ListAccounts(null).ToList();

            Assert.Equal(2, account.Count);
        }
开发者ID:safeermohammed,项目名称:azure-sdk-for-net,代码行数:26,代码来源:ProfileClientTests.cs


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