本文整理汇总了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();
}
示例2: TenantCmdletTests
public TenantCmdletTests()
{
dataStore = new MemoryDataStore();
AzureSession.DataStore = dataStore;
commandRuntimeMock = new MockCommandRuntime();
AzureRmProfileProvider.Instance.Profile = new AzureRMProfile();
}
示例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"));
}
示例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));
}
示例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";
}
示例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;
}
示例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;
}
}
示例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]);
}
示例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));
}
示例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);
}
示例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));
}
示例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));
}
示例13: EnvironmentCmdletTests
public EnvironmentCmdletTests()
{
dataStore = new MemoryDataStore();
AzureSession.DataStore = dataStore;
}
示例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);
}
示例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);
}