public PowerShellManagerTests()
        {
            _functionDirectory   = Path.Join(AppDomain.CurrentDomain.BaseDirectory, "TestScripts", "PowerShell");
            _rpcFunctionMetadata = new RpcFunctionMetadata()
            {
                Name      = "TestFuncApp",
                Directory = _functionDirectory,
                Bindings  =
                {
                    { TestInputBindingName,  new BindingInfo {
                          Direction = BindingInfo.Types.Direction.In, Type = "httpTrigger"
                      } },
                    { TestOutputBindingName, new BindingInfo {
                          Direction = BindingInfo.Types.Direction.Out, Type = "http"
                      } }
                }
            };
            _functionLoadRequest = new FunctionLoadRequest {
                FunctionId = "FunctionId", Metadata = _rpcFunctionMetadata
            };
            FunctionLoader.SetupWellKnownPaths(_functionLoadRequest);

            _testLogger  = new ConsoleLogger();
            _testManager = new PowerShellManager(_testLogger);
            _testManager.PerformWorkerLevelInitialization();

            _testInputData = new List <ParameterBinding>
            {
                new ParameterBinding
                {
                    Name = TestInputBindingName,
                    Data = new TypedData
                    {
                        String = TestStringData
                    }
                }
            };
        }
        /// <summary>
        /// Method to process a FunctionLoadRequest.
        /// FunctionLoadRequest should be processed sequentially. There is no point to process FunctionLoadRequest
        /// concurrently as a FunctionApp doesn't include a lot functions in general. Having this step sequential
        /// will make the Runspace-level initialization easier and more predictable.
        /// </summary>
        internal StreamingMessage ProcessFunctionLoadRequest(StreamingMessage request)
        {
            FunctionLoadRequest functionLoadRequest = request.FunctionLoadRequest;

            StreamingMessage response = NewStreamingMessageTemplate(
                request.RequestId,
                StreamingMessage.ContentOneofCase.FunctionLoadResponse,
                out StatusResult status);

            response.FunctionLoadResponse.FunctionId = functionLoadRequest.FunctionId;

            try
            {
                // Ideally, the initialization should happen when processing 'WorkerInitRequest', however, the 'WorkerInitRequest'
                // message doesn't provide the file path of the FunctionApp. That information is not available until the first
                // 'FunctionLoadRequest' comes in. Therefore, we run initialization here.
                if (!_isFunctionAppInitialized)
                {
                    FunctionLoader.SetupWellKnownPaths(functionLoadRequest);
                    _powerShellManager.PerformWorkerLevelInitialization();
                    _powerShellManager.PerformRunspaceLevelInitialization();

                    _isFunctionAppInitialized = true;
                }

                // Load the metadata of the function.
                _functionLoader.LoadFunction(functionLoadRequest);
            }
            catch (Exception e)
            {
                status.Status    = StatusResult.Types.Status.Failure;
                status.Exception = e.ToRpcException();
            }

            return(response);
        }