示例#1
0
        /// <summary>
        /// Management clients.
        /// </summary>
        /// <param name="context">context.</param>
        protected void SetupManagementClients(HpcCacheTestContext context)
        {
            var hpcCacheManagementClient = this.GetHpcCacheManagementClient(context);
            var resourceManagementClient = this.GetResourceManagementClient(context);
            var storageManagementClient  = this.GetStorageManagementClient(context);

            this.helper.SetupManagementClients(
                hpcCacheManagementClient,
                resourceManagementClient,
                storageManagementClient);
        }
示例#2
0
        /// <summary>
        /// RunPsTestWorkflow.
        /// </summary>
        /// <param name="logger">logger.</param>
        /// <param name="scriptBuilder">scriptBuilder.</param>
        /// <param name="cleanup">cleanup.</param>
        /// <param name="callingClassType">callingClassType.</param>
        /// <param name="mockName">mockName.</param>
        /// <param name="initialize">initialize.</param>
        protected void RunPsTestWorkflow(
            XunitTracingInterceptor logger,
            Func <string[]> scriptBuilder,
            Action cleanup,
            string callingClassType,
            string mockName,
            Action initialize = null)
        {
            this.helper.TracingInterceptor = logger;
            var d = new Dictionary <string, string>
            {
                { "Microsoft.Resources", null },
                { "Microsoft.Features", null },
                { "Microsoft.Authorization", null },
            };
            var providersToIgnore = new Dictionary <string, string>
            {
                { "Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01" },
                { "Microsoft.Azure.Management.ResourceManager.ResourceManagementClient", "2017-05-10" },
            };

            HttpMockServer.Matcher          = new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore);
            HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords");
            using (var context = new HpcCacheTestContext(callingClassType, mockName))
            {
                initialize?.Invoke();
                this.SetupManagementClients(context);

                var callingClassName = callingClassType.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries).Last();
                this.helper.SetupModules(
                    AzureModule.AzureResourceManager,
                    "ScenarioTests\\" + callingClassName + ".ps1",
                    this.helper.RMProfileModule,
                    this.helper.GetRMModulePath("Az.HPCCache.psd1"),
                    "AzureRM.Resources.ps1");

                try
                {
                    var psScripts = scriptBuilder?.Invoke();
                    if (psScripts != null)
                    {
                        this.helper.RunPowerShellTest(psScripts);
                    }
                }
                finally
                {
                    cleanup?.Invoke();
                }
            }
        }
示例#3
0
        /// <summary>
        /// RunPsTestWorkflow.
        /// </summary>
        /// <param name="logger">logger.</param>
        /// <param name="scriptBuilder">scriptBuilder.</param>
        /// <param name="cleanup">cleanup.</param>
        /// <param name="callingClassType">callingClassType.</param>
        /// <param name="mockName">mockName.</param>
        /// <param name="initialize">initialize.</param>
        protected void RunPsTestWorkflow(
            XunitTracingInterceptor logger,
            Func <string[]> scriptBuilder,
            Action cleanup,
            string callingClassType,
            string mockName,
            Action initialize = null)
        {
            this.helper.TracingInterceptor  = logger;
            HttpMockServer.Matcher          = GetRecordMatcher();
            HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords");
            using (var context = new HpcCacheTestContext(callingClassType, mockName))
            {
                initialize?.Invoke();
                this.SetupManagementClients(context);

                var callingClassName = callingClassType.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries).Last();
                this.helper.SetupModules(
                    AzureModule.AzureResourceManager,
                    "ScenarioTests\\" + callingClassName + ".ps1",
                    this.helper.RMProfileModule,
                    this.helper.GetRMModulePath("Az.HPCCache.psd1"),
                    "AzureRM.Resources.ps1");

                try
                {
                    var psScripts = scriptBuilder?.Invoke();
                    if (psScripts != null)
                    {
                        this.helper.RunPowerShellTest(psScripts);
                    }
                }
                finally
                {
                    cleanup?.Invoke();
                }
            }
        }
示例#4
0
 /// <summary>
 /// GetStorageManagementClient.
 /// </summary>
 /// <param name="context">context.</param>
 /// <returns>StorageManagementClient.</returns>
 protected StorageManagementClient GetStorageManagementClient(HpcCacheTestContext context)
 {
     return(context.GetClient <StorageManagementClient>());
 }
示例#5
0
 /// <summary>
 /// GetResourceManagementClient.
 /// </summary>
 /// <param name="context">context.</param>
 /// <returns>ResourceManagementClient.</returns>
 protected ResourceManagementClient GetResourceManagementClient(HpcCacheTestContext context)
 {
     return(context.GetClient <ResourceManagementClient>());
 }