public void RunProcessThrowsExceptionIfExecutableDoesNotExist()
        {
            Mock <ITemporaryStorageManager> storageManagerMock = new Mock <ITemporaryStorageManager>();

            storageManagerMock.Setup(mock => mock.CreateFilePath("ExternalApp.exe")).Returns("DoesNotExistsPath.exe");
            ExternalProcessManager processManager = CreateExternalProcessManager(storageManagerMock.Object);

            processManager.Initialize(baseDirectory, "");

            Assert.ThrowsException <ExternalProcessExecutableDoesNotExist>(() => processManager.RunProcess());
        }
        public void RunProcessReturnsProcessResultFromExecutable()
        {
            Mock <ITemporaryStorageManager> storageManagerMock = new Mock <ITemporaryStorageManager>();
            string executableName = "ExternalApp.exe";

            storageManagerMock.Setup(mock => mock.CreateFilePath(executableName)).Returns(Path.Combine(expectedExecutablePath, executableName));
            storageManagerMock.SetupGet(mock => mock.TemporaryDirectoryPath).Returns(expectedExecutablePath);
            ExternalProcessManager processManager = CreateExternalProcessManager(storageManagerMock.Object);

            processManager.Initialize(baseDirectory, "5");

            ProcessRunResult result = processManager.RunProcess();

            result.ProcessExitCode.Should().Be(5);
            result.Output.Should().Be($"Hello World!{Environment.NewLine}");
            result.Error.Should().Be($"Sad Trombone...{Environment.NewLine}");
        }
        public void RunProcessThrowsExceptionIfWorkingDirectoryDoesNotExist()
        {
            Mock <ITemporaryStorageManager> storageManagerMock = new Mock <ITemporaryStorageManager>();
            string executableName = "ExternalApp.exe";

            storageManagerMock.Setup(mock => mock.CreateFilePath(executableName)).Returns(Path.Combine(expectedExecutablePath, executableName));
            //storageManagerMock.SetupGet(mock => mock.TemporaryDirectoryPath).Returns(expectedExecutablePath);
            storageManagerMock.SetupGet(mock => mock.TemporaryDirectoryPath).Returns(Path.Combine(expectedExecutablePath, "DoesNotExist"));
            ExternalProcessManager processManager = CreateExternalProcessManager(storageManagerMock.Object);

            processManager.Initialize(baseDirectory, "");

            Assert.ThrowsException <ExternalProcessWorkingDirectoryDoesNotExist>(() => processManager.RunProcess());
        }