public void RunPsTestWorkflow(
Func<string[]> scriptBuilder,
Action initialize,
Action cleanup,
string callingClassType,
string mockName)
{
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.Management.Resources.ResourceManagementClient", "2016-02-01");
HttpMockServer.Matcher = new PermissiveRecordMatcherWithApiExclusion(true, d, providersToIgnore);
HttpMockServer.RecordsDirectory = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "SessionRecords");
using (MockContext context = MockContext.Start(callingClassType, mockName))
{
this.csmTestFactory = SetupCSMTestEnvironmentFactory();
SetupManagementClients(context);
helper.SetupEnvironment(AzureModule.AzureResourceManager);
var callingClassName = callingClassType
.Split(new[] { "." }, StringSplitOptions.RemoveEmptyEntries)
.Last();
helper.SetupModules(AzureModule.AzureResourceManager,
"ScenarioTests\\Common.ps1",
"ScenarioTests\\" + callingClassName + ".ps1",
"Microsoft.Azure.Commands.Batch.Test.dll",
helper.RMProfileModule,
helper.RMResourceModule,
helper.GetRMModulePath("AzureRM.Batch.psd1"),
"AzureRM.Resources.ps1");
try
{
if (initialize != null)
{
initialize();
}
if (scriptBuilder != null)
{
var psScripts = scriptBuilder();
if (psScripts != null)
{
helper.RunPowerShellTest(psScripts);
}
}
}
finally
{
if (cleanup != null)
{
cleanup();
}
}
}
}