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


C# Mocks.MockDataStore类代码示例

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


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

示例1: ProfileCmdltsTests

 public ProfileCmdltsTests() : base()
 {
     MockDataStore dataStore = new MockDataStore();
     ProfileClient.DataStore = dataStore;
     commandRuntimeMock = new Mock<ICommandRuntime>();
     SetMockData();
     AzureSession.SetCurrentContext(null, null, null);
 }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:8,代码来源:ProfileCmdltsTests.cs

示例2: ProfileMigratesOldData

        public void ProfileMigratesOldData()
        {
            MockDataStore dataStore = new MockDataStore();
            dataStore.VirtualStore[oldProfileDataPath] = oldProfileData;
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();

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

示例3: ProfileSerializeDeserializeWorks

        public void ProfileSerializeDeserializeWorks()
        {
            var dataStore = new MockDataStore();
            AzureSession.DataStore = dataStore;
            var profilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AzureSession.ProfileFile);
            var currentProfile = new AzureRMProfile(profilePath);
            var tenantId = Guid.NewGuid().ToString();
            var environment = new AzureEnvironment
            {
                Name = "testCloud",
                Endpoints = { { AzureEnvironment.Endpoint.ActiveDirectory, "http://contoso.com" } }
            };
            var account = new AzureAccount
            {
                Id = "[email protected]",
                Type = AzureAccount.AccountType.User,
                Properties = { { AzureAccount.Property.Tenants, tenantId } }
            };
            var sub = new AzureSubscription
            {
                Account = account.Id,
                Environment = environment.Name,
                Id = new Guid(),
                Name = "Contoso Test Subscription",
                Properties = { { AzureSubscription.Property.Tenants, tenantId } }
            };
            var tenant = new AzureTenant
            {
                Id = new Guid(tenantId),
                Domain = "contoso.com"
            };

            currentProfile.Context = new AzureContext(sub, account, environment, tenant);
            currentProfile.Environments[environment.Name] = environment;
            currentProfile.Context.TokenCache = new byte[] { 1, 2, 3, 4, 5, 6, 8, 9, 0 };

            AzureRMProfile deserializedProfile;
            // Round-trip the exception: Serialize and de-serialize with a BinaryFormatter
            BinaryFormatter bf = new BinaryFormatter();
            using (MemoryStream ms = new MemoryStream())
            {
                // "Save" object state
                bf.Serialize(ms, currentProfile);

                // Re-use the same stream for de-serialization
                ms.Seek(0, 0);

                // Replace the original exception with de-serialized one
                deserializedProfile = (AzureRMProfile)bf.Deserialize(ms);
            }
            Assert.NotNull(deserializedProfile);
            var jCurrentProfile = currentProfile.ToString();
            var jDeserializedProfile = deserializedProfile.ToString();
            Assert.Equal(jCurrentProfile, jDeserializedProfile);
        }
开发者ID:rohmano,项目名称:azure-powershell,代码行数:55,代码来源:AzureRMProfileTests.cs

示例4: ProfileSerializeDeserializeWorks

        public void ProfileSerializeDeserializeWorks()
        {
            var dataStore = new MockDataStore();
            var currentProfile = new AzureProfile(Path.Combine(AzureSession.ProfileDirectory, AzureSession.ProfileFile));
            AzureSession.DataStore = dataStore;
            var client = new ProfileClient(currentProfile);
            var tenant = Guid.NewGuid().ToString();
            var environment = new AzureEnvironment
            {
                Name = "testCloud",
                Endpoints = { { AzureEnvironment.Endpoint.ActiveDirectory, "http://contoso.com" } }
            };
            var account = new AzureAccount
            {
                Id = "[email protected]",
                Type = AzureAccount.AccountType.User,
                Properties = { { AzureAccount.Property.Tenants, tenant } }
            };
            var sub = new AzureSubscription
            {
                Account = account.Id,
                Environment = environment.Name,
                Id = new Guid(),
                Name = "Contoso Test Subscription",
                Properties = { { AzureSubscription.Property.Tenants, tenant } }
            };

            client.AddOrSetEnvironment(environment);
            client.AddOrSetAccount(account);
            client.AddOrSetSubscription(sub);

            AzureProfile deserializedProfile;
            // Round-trip the exception: Serialize and de-serialize with a BinaryFormatter
            BinaryFormatter bf = new BinaryFormatter();
            using (MemoryStream ms = new MemoryStream())
            {
                // "Save" object state
                bf.Serialize(ms, currentProfile);

                // Re-use the same stream for de-serialization
                ms.Seek(0, 0);

                // Replace the original exception with de-serialized one
                deserializedProfile = (AzureProfile)bf.Deserialize(ms);
            }
            Assert.NotNull(deserializedProfile);
            var jCurrentProfile = JsonConvert.SerializeObject(currentProfile);
            var jDeserializedProfile = JsonConvert.SerializeObject(deserializedProfile);
            Assert.Equal(jCurrentProfile, jDeserializedProfile);
        }
开发者ID:theadriangreen,项目名称:azure-sdk-for-net,代码行数:50,代码来源:ProfileTests.cs

示例5: ProfileSaveDoesNotSerializeContext

        public void ProfileSaveDoesNotSerializeContext()
        {
            var dataStore = new MockDataStore();
            var profilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, AzureSession.ProfileFile);
            var profile = new AzureSMProfile(profilePath);
            AzureSession.DataStore = dataStore;
            var tenant = Guid.NewGuid().ToString();
            var environment = new AzureEnvironment
            {
                Name = "testCloud",
                Endpoints = { { AzureEnvironment.Endpoint.ActiveDirectory, "http://contoso.com" } }
            };
            var account = new AzureAccount
            {
                Id = "[email protected]",
                Type = AzureAccount.AccountType.User,
                Properties = { { AzureAccount.Property.Tenants, tenant } }
            };
            var sub = new AzureSubscription
            {
                Account = account.Id,
                Environment = environment.Name,
                Id = new Guid(),
                Name = "Contoso Test Subscription",
                Properties = { { AzureSubscription.Property.Tenants, tenant } }
            };

            profile.Environments[environment.Name] = environment;
            profile.Accounts[account.Id] = account;
            profile.Subscriptions[sub.Id] = sub;

            profile.Save();

            var profileFile = profile.ProfilePath;
            string profileContents = dataStore.ReadFileAsText(profileFile);
            var readProfile = JsonConvert.DeserializeObject<Dictionary<string, object>>(profileContents);
            Assert.False(readProfile.ContainsKey("DefaultContext"));
            AzureSMProfile parsedProfile = new AzureSMProfile();
            var serializer = new JsonProfileSerializer();
            Assert.True(serializer.Deserialize(profileContents, parsedProfile));
            Assert.NotNull(parsedProfile);
            Assert.NotNull(parsedProfile.Environments);
            Assert.True(parsedProfile.Environments.ContainsKey(environment.Name));
            Assert.NotNull(parsedProfile.Accounts);
            Assert.True(parsedProfile.Accounts.ContainsKey(account.Id));
            Assert.NotNull(parsedProfile.Subscriptions);
            Assert.True(parsedProfile.Subscriptions.ContainsKey(sub.Id));
        }
开发者ID:Azure,项目名称:azure-powershell,代码行数:48,代码来源:AzureSMProfileTests.cs

示例6: RefreshSubscriptionsListsAllSubscriptions

        public void RefreshSubscriptionsListsAllSubscriptions()
        {
            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);
            PowerShellUtilities.GetCurrentModeOverride = () => AzureModule.AzureServiceManagement;

            var subscriptions = client.RefreshSubscriptions(azureEnvironment);

            Assert.Equal(4, subscriptions.Count);
            Assert.Equal(1, subscriptions.Count(s => s.Id == new Guid(rdfeSubscription1.SubscriptionId)));
            Assert.Equal(1, subscriptions.Count(s => s.Id == new Guid(rdfeSubscription2.SubscriptionId)));
            Assert.Equal(1, subscriptions.Count(s => s.Id == new Guid(csmSubscription1.SubscriptionId)));
            Assert.True(subscriptions.All(s => s.Environment == "Test"));
            Assert.True(subscriptions.All(s => s.Account == "test"));
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:20,代码来源:ProfileClientTests.cs

示例7: RefreshSubscriptionsWorksWithMooncake

        public void RefreshSubscriptionsWorksWithMooncake()
        {
            SetMocks(new[] { rdfeSubscription1, rdfeSubscription2 }.ToList(), new[] { csmSubscription1, csmSubscription1withDuplicateId }.ToList());
            MockDataStore dataStore = new MockDataStore();
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();
            PowerShellUtilities.GetCurrentModeOverride = () => AzureModule.AzureResourceManager;
            
            client.Profile.Accounts[azureAccount.Id] = azureAccount;

            var subscriptions = client.RefreshSubscriptions(client.Profile.Environments[EnvironmentName.AzureChinaCloud]);

            Assert.Equal(2, subscriptions.Count);
            Assert.Equal(2, subscriptions.Count(s => s.Account == "test"));
            Assert.Equal(1, subscriptions.Count(s => s.Id == new Guid(rdfeSubscription1.SubscriptionId)));
            Assert.Equal(1, subscriptions.First(s => s.Id == new Guid(rdfeSubscription1.SubscriptionId)).GetPropertyAsArray(AzureSubscription.Property.SupportedModes).Count());
            Assert.Equal(1, subscriptions.Count(s => s.Id == new Guid(rdfeSubscription2.SubscriptionId)));
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:18,代码来源:ProfileClientTests.cs

示例8: RemoveAzureAccountRemovesInMemoryAccount

        public void RemoveAzureAccountRemovesInMemoryAccount()
        {
            MockDataStore dataStore = new MockDataStore();
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();
            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;
            AzureSession.SetCurrentContext(azureSubscription1, azureEnvironment, azureAccount);

            client.RemoveAccount(azureAccount.Id);

            Assert.Equal("test2", AzureSession.CurrentContext.Account.Id);
            Assert.Equal("test2", AzureSession.CurrentContext.Subscription.Account);
            Assert.Equal(azureSubscription1.Id, AzureSession.CurrentContext.Subscription.Id);

            client.RemoveAccount("test2");

            Assert.Null(AzureSession.CurrentContext.Account);
            Assert.Null(AzureSession.CurrentContext.Subscription);
            Assert.Equal(EnvironmentName.AzureCloud, AzureSession.CurrentContext.Environment.Name);
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:34,代码来源:ProfileClientTests.cs

示例9: 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

示例10: 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

示例11: ProfileMigratesAccountsAndDefaultSubscriptions

        public void ProfileMigratesAccountsAndDefaultSubscriptions()
        {
            MockDataStore dataStore = new MockDataStore();
            dataStore.VirtualStore[oldProfileDataPath] = oldProfileData;
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();

            // Verify Environment migration
            Assert.Equal(4, client.Profile.Environments.Count);
            Assert.Equal("Current", client.Profile.Environments["Current"].Name);
            Assert.Equal("Dogfood", client.Profile.Environments["Dogfood"].Name);
            Assert.Equal("https://login.windows-ppe.net/", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.AdTenant]);
            Assert.Equal("https://management.core.windows.net/", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.ActiveDirectoryServiceEndpointResourceId]);
            Assert.Equal("https://df.gallery.azure-test.net", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.Gallery]);
            Assert.Equal("https://windows.azure-test.net", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.ManagementPortalUrl]);
            Assert.Equal("https://auxnext.windows.azure-test.net/publishsettings/index", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.PublishSettingsFileUrl]);
            Assert.Equal("https://api-dogfood.resources.windows-int.net", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.ResourceManager]);
            Assert.Equal("https://management-preview.core.windows-int.net/", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.ServiceManagement]);
            Assert.Equal(".database.windows.net", client.Profile.Environments["Dogfood"].Endpoints[AzureEnvironment.Endpoint.SqlDatabaseDnsSuffix]);
            
            // Verify subscriptions
            Assert.Equal(3, client.Profile.Subscriptions.Count);
            Assert.False(client.Profile.Subscriptions.ContainsKey(new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1E")));
            Assert.True(client.Profile.Subscriptions.ContainsKey(new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F")));
            Assert.Equal("Test 2", client.Profile.Subscriptions[new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F")].Name);
            Assert.True(client.Profile.Subscriptions[new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F")].IsPropertySet(AzureSubscription.Property.Default));
            Assert.Equal("[email protected]", client.Profile.Subscriptions[new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F")].Account);
            Assert.Equal("Dogfood", client.Profile.Subscriptions[new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F")].Environment);
            Assert.Equal("123", client.Profile.Subscriptions[new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F")].Properties[AzureSubscription.Property.Tenants]);
            Assert.True(client.Profile.Subscriptions.ContainsKey(new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f")));
            Assert.Equal("Test 3", client.Profile.Subscriptions[new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f")].Name);
            Assert.False(client.Profile.Subscriptions[new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f")].IsPropertySet(AzureSubscription.Property.Default));
            Assert.Equal("[email protected]", client.Profile.Subscriptions[new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f")].Account);
            Assert.Equal("72f988bf-86f1-41af-91ab-2d7cd011db47", client.Profile.Subscriptions[new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f")].Properties[AzureSubscription.Property.Tenants]);
            Assert.Equal(EnvironmentName.AzureCloud, client.Profile.Subscriptions[new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f")].Environment);
            Assert.Equal(EnvironmentName.AzureChinaCloud, client.Profile.Subscriptions[new Guid("c14d7dc5-ed4d-4346-a02f-9f1bcf78fb66")].Environment);

            // Verify accounts
            Assert.Equal(2, client.Profile.Accounts.Count);
            Assert.Equal("[email protected]", client.Profile.Accounts["[email protected]"].Id);
            Assert.Equal(AzureAccount.AccountType.User, client.Profile.Accounts["[email protected]"].Type);
            Assert.True(client.Profile.Accounts["[email protected]"].GetPropertyAsArray(AzureAccount.Property.Subscriptions)
                .Contains(new Guid("06E3F6FD-A3AA-439A-8FC4-1F5C41D2AD1F").ToString()));
            Assert.True(client.Profile.Accounts["[email protected]"].GetPropertyAsArray(AzureAccount.Property.Subscriptions)
                .Contains(new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f").ToString()));
            Assert.True(client.Profile.Accounts["3AF24D48B97730E5C4C9CCB12397B5E046F79E09"].GetPropertyAsArray(AzureAccount.Property.Subscriptions)
                .Contains(new Guid("d1e52cbc-b073-42e2-a0a0-c2f547118a6f").ToString()));
            Assert.True(client.Profile.Accounts["[email protected]"].GetPropertyAsArray(AzureAccount.Property.Tenants)
                .Contains("72f988bf-86f1-41af-91ab-2d7cd011db47"));
            Assert.True(client.Profile.Accounts["[email protected]"].GetPropertyAsArray(AzureAccount.Property.Tenants)
                .Contains("123"));
            Assert.Equal("3AF24D48B97730E5C4C9CCB12397B5E046F79E09", client.Profile.Accounts["3AF24D48B97730E5C4C9CCB12397B5E046F79E09"].Id);
            Assert.Equal(AzureAccount.AccountType.Certificate, client.Profile.Accounts["3AF24D48B97730E5C4C9CCB12397B5E046F79E09"].Type);
            Assert.Equal(0, client.Profile.Accounts["3AF24D48B97730E5C4C9CCB12397B5E046F79E09"].GetPropertyAsArray(AzureAccount.Property.Tenants).Length);
            Assert.Equal(2, client.Profile.Accounts["3AF24D48B97730E5C4C9CCB12397B5E046F79E09"].GetPropertyAsArray(AzureAccount.Property.Subscriptions).Length);
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:56,代码来源:ProfileClientTests.cs

示例12: SetAzureSubscriptionAsCurrentSetsCurrent

        public void SetAzureSubscriptionAsCurrentSetsCurrent()
        {
            MockDataStore dataStore = new MockDataStore();
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();
            client.Profile.Accounts[azureAccount.Id] = azureAccount;
            client.AddOrSetEnvironment(azureEnvironment);
            client.AddOrSetSubscription(azureSubscription1);
            client.AddOrSetSubscription(azureSubscription2);

            Assert.Null(AzureSession.CurrentContext.Subscription);

            client.SetSubscriptionAsCurrent(azureSubscription2.Name, azureSubscription2.Account);

            Assert.Equal(azureSubscription2.Id, AzureSession.CurrentContext.Subscription.Id);
            Assert.Throws<ArgumentException>(() => client.SetSubscriptionAsCurrent("bad", null));
            Assert.Throws<ArgumentNullException>(() => client.SetSubscriptionAsCurrent(null, null));
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:18,代码来源:ProfileClientTests.cs

示例13: GetCurrentEnvironmentReturnsCorrectValue

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

            AzureSession.SetCurrentContext(azureSubscription1, azureEnvironment, azureAccount);

            var newEnv = client.GetEnvironmentOrDefault(azureEnvironment.Name);

            Assert.Equal(azureEnvironment.Name, newEnv.Name);
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:12,代码来源:ProfileClientTests.cs

示例14: GetAzureEnvironmentReturnsCorrectValue

        public void GetAzureEnvironmentReturnsCorrectValue()
        {
            MockDataStore dataStore = new MockDataStore();
            ProfileClient.DataStore = dataStore;
            ProfileClient client = new ProfileClient();
            client.AddOrSetEnvironment(azureEnvironment);

            Assert.Equal(EnvironmentName.AzureCloud, AzureSession.CurrentContext.Environment.Name);

            var defaultEnv = client.GetEnvironmentOrDefault(null);

            Assert.Equal(EnvironmentName.AzureCloud, defaultEnv.Name);

            var newEnv = client.GetEnvironmentOrDefault(azureEnvironment.Name);

            Assert.Equal(azureEnvironment.Name, newEnv.Name);

            Assert.Throws<ArgumentException>(() => client.GetEnvironmentOrDefault("bad"));
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:19,代码来源:ProfileClientTests.cs

示例15: SetAzureEnvironmentUpdatesEnvironment

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

            Assert.Equal(2, client.Profile.Environments.Count);

            Assert.Throws<ArgumentNullException>(() => client.AddOrSetEnvironment(null));
            
            var env2 = client.AddOrSetEnvironment(azureEnvironment);
            Assert.Equal(env2.Name, azureEnvironment.Name);
            Assert.NotNull(env2.Endpoints[AzureEnvironment.Endpoint.ServiceManagement]);
            AzureEnvironment newEnv = new AzureEnvironment
            {
                Name = azureEnvironment.Name
            };
            newEnv.Endpoints[AzureEnvironment.Endpoint.Graph] = "foo";
            env2 = client.AddOrSetEnvironment(newEnv);
            Assert.Equal("foo", env2.Endpoints[AzureEnvironment.Endpoint.Graph]);
            Assert.NotNull(env2.Endpoints[AzureEnvironment.Endpoint.ServiceManagement]);
        }
开发者ID:djrosanova,项目名称:azure-sdk-tools,代码行数:22,代码来源:ProfileClientTests.cs


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