Exemple #1
0
        public void IfStandardInputContentIsNotSetThenStandardInputIsNotRedirected()
        {
            ProcessInfo info    = new ProcessInfo("temp");
            Process     process = info.CreateProcess();

            Assert.IsTrue(!process.StartInfo.RedirectStandardInput);
        }
Exemple #2
0
        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);
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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));
        }
Exemple #5
0
        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);
        }