private Process CreateProcess()
        {
            var dummyNodeJSProcessFactory          = new NodeJSProcessFactory(null);
            ProcessStartInfo dummyProcessStartInfo = dummyNodeJSProcessFactory.CreateStartInfo(_dummyLongRunningScript);

            return(dummyNodeJSProcessFactory.CreateProcess(dummyProcessStartInfo));
        }
        private Process CreateNodeJSProcess()
        {
            // Get server script
            var    embeddedResourcesService = new EmbeddedResourcesService();
            string serverScript             = embeddedResourcesService.ReadAsString(typeof(HttpNodeJSService), HttpNodeJSService.SERVER_SCRIPT_NAME);

            // Create process
            var nodeJSProcessFactory          = new NodeJSProcessFactory(null);
            ProcessStartInfo processStartInfo = nodeJSProcessFactory.CreateStartInfo(serverScript);

            return(nodeJSProcessFactory.CreateProcess(processStartInfo));
        }
        public void CreateStartInfo_CreatesStartInfo()
        {
            // Arrange
            const string dummyNodeServerScript         = "dummyNodeServerScript";
            const string dummyNodeAndV8Options         = "dummyNodeAndV8Options";
            const int    dummyPort                     = 123; // Arbitrary
            const string dummyProjectPath              = "dummyProjectPath";
            const string dummyEnvironmentVariable      = "dummyEnvironmentVariable";
            const string dummyEnvironmentVariableValue = "dummyEnvironmentVariableValue";
            var          dummyEnvironmentVariables     = new Dictionary <string, string> {
                { dummyEnvironmentVariable, dummyEnvironmentVariableValue }
            };
            var dummyNodeJSProcessOptions = new NodeJSProcessOptions
            {
                NodeAndV8Options     = dummyNodeAndV8Options,
                Port                 = dummyPort,
                ProjectPath          = dummyProjectPath,
                EnvironmentVariables = dummyEnvironmentVariables
            };
            Mock <IOptions <NodeJSProcessOptions> > mockOptionsAccessor = _mockRepository.Create <IOptions <NodeJSProcessOptions> >();

            mockOptionsAccessor.Setup(o => o.Value).Returns(dummyNodeJSProcessOptions);
            NodeJSProcessFactory testSubject = CreateNodeJSProcessFactory(mockOptionsAccessor.Object);

            // Act
            ProcessStartInfo result = testSubject.CreateStartInfo(dummyNodeServerScript);

            // Assert
            int currentProcessPid = Process.GetCurrentProcess().Id;

            Assert.Equal($"{dummyNodeAndV8Options} -e \"{dummyNodeServerScript}\" -- --parentPid {currentProcessPid} --port {dummyPort}", result.Arguments);
            Assert.False(result.UseShellExecute);
            Assert.True(result.RedirectStandardInput);
            Assert.True(result.RedirectStandardOutput);
            Assert.True(result.RedirectStandardError);
            Assert.Equal(dummyProjectPath, result.WorkingDirectory);
            result.Environment.TryGetValue(dummyEnvironmentVariable, out string resultEnvironmentVariableValue);
            Assert.NotNull(resultEnvironmentVariableValue);
            Assert.Equal(dummyEnvironmentVariableValue, resultEnvironmentVariableValue);
        }