public void IfStandardInputContentIsNotSetThenStandardInputIsNotRedirected() { ProcessInfo info = new ProcessInfo("temp"); Process process = info.CreateProcess(); Assert.IsTrue(!process.StartInfo.RedirectStandardInput); }
public void CreateProcessCreatesTheProcess() { var fileSystemMock = new Mock <IFileSystem>(MockBehavior.Strict); fileSystemMock.Setup(fs => fs.CheckIfFileExists(It.IsAny <string>())).Returns(false); var filename = "somewhere"; var info = new ProcessInfo(filename); var process = info.CreateProcess(fileSystemMock.Object); Assert.AreEqual(filename, process.StartInfo.FileName); }
public void IfStandardInputContentIsSetThenStandardInputIsRedirected() { ProcessInfo info = new ProcessInfo("temp"); info.StandardInputContent = "Some content"; Process process = info.CreateProcess(); Assert.IsTrue(process.StartInfo.RedirectStandardInput); Assert.IsTrue(!process.StartInfo.UseShellExecute); }
public void CreateProcessFailsIfTheDirectoryDoesNotExist() { var fileSystemMock = new Mock <IFileSystem>(MockBehavior.Strict); fileSystemMock.Setup(fs => fs.CheckIfFileExists(It.IsAny <string>())).Returns(false); fileSystemMock.Setup(fs => fs.CheckIfDirectoryExists(It.IsAny <string>())).Returns(false); var filename = "somewhere"; var info = new ProcessInfo(filename); info.WorkingDirectory = "d:\\somewhereelse"; Assert.Throws <DirectoryNotFoundException>(() => info.CreateProcess(fileSystemMock.Object)); }
public void CreateProcessUpdatesTheFilename() { var fileSystemMock = new Mock <IFileSystem>(MockBehavior.Strict); fileSystemMock.Setup(fs => fs.CheckIfFileExists(It.IsAny <string>())).Returns(true); fileSystemMock.Setup(fs => fs.CheckIfDirectoryExists(It.IsAny <string>())).Returns(true); var filename = "somewhere"; var directory = Path.GetTempPath(); var info = new ProcessInfo(filename, null, directory); var process = info.CreateProcess(fileSystemMock.Object); Assert.AreEqual(Path.Combine(directory, filename), process.StartInfo.FileName); }