/// <summary> /// Initialize unit tests with configuration /// </summary> static TestBase() { XElement element; using (FileStream stream = new FileStream(TestConfigurations.DefaultTestConfigFilePath, FileMode.Open)) { element = XElement.Load(stream); } TestConfigurations configurations = TestConfigurations.ReadFromXml(element); TestBase.Initialize(configurations); }
static TestBase() { try { XElement element = XElement.Load(TestConfigurations.DefaultTestConfigFilePath); TestConfigurations configurations = TestConfigurations.ReadFromXml(element); TestBase.Initialize(configurations); } catch (System.IO.FileNotFoundException) { throw new System.IO.FileNotFoundException("To run tests you need to supply a TestConfigurations.xml file with credentials in the Test/Common folder. Use TestConfigurationsTemplate.xml as a template."); } }
private static void Initialize(TestConfigurations configurations) { TestBase.TargetTenantConfig = configurations.TenantConfigurations.Single(config => config.TenantName == configurations.TargetTenantName); TestBase.StorageCredentials = new StorageCredentials(TestBase.TargetTenantConfig.AccountName, TestBase.TargetTenantConfig.AccountKey); TestBase.CurrentTenantType = TargetTenantConfig.TenantType; try { TestBase.PremiumBlobTenantConfig = configurations.TenantConfigurations.Single(config => config.TenantName == configurations.TargetPremiumBlobTenantName); TestBase.PremiumBlobStorageCredentials = new StorageCredentials(TestBase.PremiumBlobTenantConfig.AccountName, TestBase.PremiumBlobTenantConfig.AccountKey); } catch (InvalidOperationException) { } #if WINDOWS_DESKTOP System.Threading.ThreadPool.SetMinThreads(100, 100); #endif }
public static TestConfigurations ReadFromXml(XElement testConfigurationsElement) { TestConfigurations result = new TestConfigurations(); result.TargetTenantName = (string)testConfigurationsElement.Element("TargetTestTenant"); result.TargetPremiumBlobTenantName = (string)testConfigurationsElement.Element("TargetPremiumBlobTenant"); result.TargetOauthTenantName = (string)testConfigurationsElement.Element("TargetOauthTenant"); List <TenantConfiguration> tenantConfigurationList = new List <TenantConfiguration>(); foreach (XElement tenantConfigurationElement in testConfigurationsElement.Element("TenantConfigurations").Elements("TenantConfiguration")) { TenantConfiguration config = new TenantConfiguration { TenantName = (string)tenantConfigurationElement.Element("TenantName"), AccountName = (string)tenantConfigurationElement.Element("AccountName"), AccountKey = (string)tenantConfigurationElement.Element("AccountKey"), EncryptionScope = (string)tenantConfigurationElement.Element("EncryptionScope"), BlobServiceEndpoint = (string)tenantConfigurationElement.Element("BlobServiceEndpoint"), FileServiceEndpoint = (string)tenantConfigurationElement.Element("FileServiceEndpoint"), QueueServiceEndpoint = (string)tenantConfigurationElement.Element("QueueServiceEndpoint"), TableServiceEndpoint = (string)tenantConfigurationElement.Element("TableServiceEndpoint"), BlobServiceSecondaryEndpoint = (string)tenantConfigurationElement.Element("BlobServiceSecondaryEndpoint"), FileServiceSecondaryEndpoint = (string)tenantConfigurationElement.Element("FileServiceSecondaryEndpoint"), QueueServiceSecondaryEndpoint = (string)tenantConfigurationElement.Element("QueueServiceSecondaryEndpoint"), TableServiceSecondaryEndpoint = (string)tenantConfigurationElement.Element("TableServiceSecondaryEndpoint"), TenantType = (TenantType)Enum.Parse(typeof(TenantType), (string)tenantConfigurationElement.Element("TenantType"), true), BlobSecurePortOverride = (string)tenantConfigurationElement.Element("BlobSecurePortOverride"), FileSecurePortOverride = (string)tenantConfigurationElement.Element("FileSecurePortOverride"), QueueSecurePortOverride = (string)tenantConfigurationElement.Element("QueueSecurePortOverride"), TableSecurePortOverride = (string)tenantConfigurationElement.Element("TableSecurePortOverride"), ActiveDirectoryApplicationId = (string)tenantConfigurationElement.Element("ActiveDirectoryApplicationId"), ActiveDirectoryApplicationSecret = (string)tenantConfigurationElement.Element("ActiveDirectoryApplicationSecret"), ActiveDirectoryTenantId = (string)tenantConfigurationElement.Element("ActiveDirectoryTenantId"), ActiveDirectoryAuthEndpoint = (string)tenantConfigurationElement.Element("ActiveDirectoryAuthEndpoint") }; tenantConfigurationList.Add(config); } result.TenantConfigurations = tenantConfigurationList; return(result); }