public static ScriptTaskContext ExeContext(bool debugging = true, ServiceManager services = null) { ScriptTaskContext taskContext = new ScriptTaskContext(); RuntimeErrors = new RuntimeErrorCollector(); taskContext.SetErrorListener(RuntimeErrors.ReportError); var logger = new LoggerRoot("", false, "TestRun", "Starting"); if (debugging) { logger.IsDebugging = true; } var taskStatusUpdater = new Mocks.ExecutionScopeStatusUpdaterMock(); ILoadedFilesManager loadedFiles = null; TaskManager taskManager = null; if (services != null) { loadedFiles = services.Get <ILoadedFilesManager>(); taskManager = services.Get <TaskManager>(); } else { IService service; loadedFiles = new LoadedFilesManager(out service); taskManager = new TaskManager(out service); } taskContext.Setup(logger.m_rootLogger, ContextLogOption.Normal, taskStatusUpdater, loadedFiles, taskManager); return(taskContext); }
internal static ServiceManager.IServiceManagerAdministration CreateFileParsingSetup(Assembly testAssembly, params ScriptFile[] files) { ServiceManager.IServiceManagerAdministration services = ServiceManager.Create(); LastServiceManager = services; IService service; var addonManager = new AddonManager(null, out service); services.Manager.Register(service); var objectManager = new DynamicObjectManager(out service); services.Manager.Register(service); var loadedFiles = new LoadedFilesManager(out service); services.Manager.Register(service); var mainLogger = new MainLogger(out service); services.Manager.Register(service); var taskManager = new TaskManager(out service); services.Manager.Register(service); TaskContextDummy taskContext = new TaskContextDummy(); services.StartServices(taskContext); addonManager.AddAssembly(typeof(System.Convert).Assembly, false); addonManager.AddAssembly(typeof(Math).Assembly, false); addonManager.AddAssembly(typeof(Enumerable).Assembly, false); addonManager.AddAssembly(AddonManager.StepBroCoreAssembly, true); if (testAssembly != null) { addonManager.AddAssembly(testAssembly, false); } foreach (var f in files) { loadedFiles.RegisterLoadedFile(f); } return(services); }