public static void ClassInitialize(TestContext testContext) { if (!GlobalTestSettings.RunNetworkTests) { return; } AdapterRegistry.RegisterAdapter( AzureStorageAdapter.TargetTypeId, typeof(AzureStorageAdapter), typeof(AzureStorageAdapterConfiguration)); string accountInfoFilePath = Path.Combine( Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), "SyncProTesting", "AzureStorageAccountInfo.json"); if (File.Exists(accountInfoFilePath)) { string fileContent = File.ReadAllText(accountInfoFilePath); accountInfo = JsonConvert.DeserializeObject <AzureStorageAdapterConfiguration>(fileContent); return; } CredentialResult credentials; try { credentials = CredentialHelper.PromptForCredentials( "Enter your storage account name (username) and account key (password)"); } catch (Win32Exception win32Exception) when(win32Exception.NativeErrorCode == (int)NativeMethods.CredUI.CredUIReturnCodes.ERROR_CANCELLED) { Assert.Inconclusive("Azure storage credentials are required to run tests"); // ReSharper disable once HeuristicUnreachableCode return; } accountInfo = new AzureStorageAdapterConfiguration { AccountName = credentials.Username, AccountKey = credentials.Password, ContainerName = DefaultContainerName }; string serializedInfo = JsonConvert.SerializeObject(accountInfo, Formatting.Indented); File.WriteAllText(accountInfoFilePath, serializedInfo); }
protected override AzureStorageAdapter CreateDestinationAdapter( SyncRelationship newRelationship, string testMethodName) { var testAccountInfo = new AzureStorageAdapterConfiguration { AccountName = accountInfo.AccountName, AccountKey = accountInfo.AccountKey, ContainerName = TestingContainerName }; AzureStorageAdapter destAdapter = new AzureStorageAdapter(newRelationship, testAccountInfo); destAdapter.TypedConfiguration.IsOriginator = false; destAdapter.InitializeClient(); return(destAdapter); }