Created
April 13, 2018 10:08
-
-
Save petesh/89c081691532b98dd3ff2aa116d20b58 to your computer and use it in GitHub Desktop.
Simple test cs code to test passing/failure - compile with csc simpletest.cs, run with mono simpletest.exe
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
public class simpletest | |
{ | |
static public void Main () | |
{ | |
// start with working situation | |
var psi = new ProcessStartInfo() { | |
FileName = "/usr/bin/7z", | |
Arguments = "a bob.7z simpletest.cs", | |
UseShellExecute = false | |
}; | |
Console.WriteLine(">>> I expect this to work <<<"); | |
var proc = new Process() { StartInfo = psi, }; | |
proc.Start(); | |
proc.WaitForExit(); | |
Console.WriteLine(">>> I expect this to work <<<"); | |
psi.UseShellExecute = true; | |
proc = new Process() { StartInfo = psi, }; | |
proc.Start(); | |
proc.WaitForExit(); | |
Console.WriteLine(">>> I expect this to fail with the missing process error <<<"); | |
psi.FileName = "/usr/bin/7zz"; | |
psi.UseShellExecute = false; | |
proc = new Process() { StartInfo = psi, }; | |
try { | |
proc.Start(); | |
proc.WaitForExit(); | |
} catch (System.ComponentModel.Win32Exception ex) { | |
Console.WriteLine(ex); | |
} | |
Console.WriteLine(">>> I expect this to fail with the xdg-open error <<<"); | |
psi.UseShellExecute = true; | |
proc = new Process() { StartInfo = psi, }; | |
proc.Start(); | |
proc.WaitForExit(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment