SetupEnvironment() public method

This overrides the default subscription and default account. This allows the test to get the tenant id in the test.
public SetupEnvironment ( ) : void
return void
        protected void RunPowerShellTest(params string[] scripts)
        {
            //HttpMockServer.Matcher = new PermissiveRecordMatcher();
            Dictionary <string, string> d = new Dictionary <string, string>();

            d.Add("Microsoft.Resources", null);
            d.Add("Microsoft.Features", null);
            d.Add("Microsoft.Authorization", null);
            var providersToIgnore = new Dictionary <string, string>();

            providersToIgnore.Add("Microsoft.Azure.Graph.RBAC.GraphRbacManagementClient", "1.42-previewInternal");
            providersToIgnore.Add("Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01");
            HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore);
            // Enable undo functionality as well as mock recording
            using (UndoContext context = UndoContext.Current)
            {
                // Configure recordings
                context.Start(TestUtilities.GetCallingClass(2), TestUtilities.GetCurrentMethodName(2));

                SetupManagementClients();

                helper.SetupEnvironment();

                helper.SetupModules(AzureModule.AzureResourceManager,
                                    "ScenarioTests\\Common.ps1",
                                    "ScenarioTests\\" + this.GetType().Name + ".ps1",
                                    helper.RMProfileModule,
                                    helper.RMResourceModule,
                                    helper.RMStorageDataPlaneModule,
                                    helper.RMStorageModule,
                                    helper.GetRMModulePath(@"AzureRM.Insights.psd1"),
                                    helper.GetRMModulePath(@"AzureRM.Sql.psd1"));
                helper.RunPowerShellTest(scripts);
            }
        }
Esempio n. 2
0
        protected void RunPowerShellTest(params string[] scripts)
        {
            HttpMockServer.Matcher = new PermissiveRecordMatcher();
            // Enable undo functionality as well as mock recording
            using (UndoContext context = UndoContext.Current)
            {
                // Configure recordings
                context.Start(TestUtilities.GetCallingClass(2), TestUtilities.GetCurrentMethodName(2));

                SetupManagementClients();

                helper.SetupEnvironment();

                helper.SetupModules(AzureModule.AzureProfile, "ScenarioTests\\Common.ps1",
                                    "ScenarioTests\\" + this.GetType().Name + ".ps1");

                helper.RunPowerShellTest(scripts);
            }
        }
Esempio n. 3
0
        protected void RunPowerShellTest(params string[] scripts)
        {
            TestExecutionHelpers.SetUpSessionAndProfile();
            var callingClassType = TestUtilities.GetCallingClass(2);
            var mockName         = TestUtilities.GetCurrentMethodName(2);

            Dictionary <string, string> d = new Dictionary <string, string>();

            d.Add("Microsoft.Resources", null);
            d.Add("Microsoft.Features", null);
            d.Add("Microsoft.Authorization", null);
            d.Add("Microsoft.Network", null);
            var providersToIgnore = new Dictionary <string, string>();

            providersToIgnore.Add("Microsoft.Azure.Graph.RBAC.Version1_6.GraphRbacManagementClient", "1.42-previewInternal");
            providersToIgnore.Add("Microsoft.Azure.Management.Resources.ResourceManagementClient", "2016-02-01");
            HttpMockServer.Matcher          = new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore);
            HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords");

            // Enable undo functionality as well as mock recording
            using (RestTestFramework.MockContext context = RestTestFramework.MockContext.Start(callingClassType, mockName))
            {
                SetupManagementClients(context);

                helper.SetupEnvironment();

                helper.SetupModules(AzureModule.AzureResourceManager,
                                    "ScenarioTests\\Common.ps1",
                                    "ScenarioTests\\" + this.GetType().Name + ".ps1",
                                    helper.RMProfileModule,
                                    helper.RMResourceModule,
                                    helper.RMStorageDataPlaneModule,
                                    helper.GetRMModulePath(@"AzureRM.Insights.psd1"),
                                    helper.GetRMModulePath(@"AzureRM.Sql.psd1"),
                                    "AzureRM.Storage.ps1",
                                    "AzureRM.Resources.ps1",
                                    helper.RMNetworkModule);
                helper.RunPowerShellTest(scripts);
            }
        }