public void DirectoryAsOutFileTest() { // Create a temp directory and try to pass it to mse string tempName = Path.GetTempFileName(); File.Delete(tempName); tempName += "d"; Directory.CreateDirectory(tempName); ArgumentExecuter target = new ArgumentExecuter(new string[] { "/p", "/o", tempName }); try { target.ExecuteArguments(); Assert.Fail("Invalid out file test failed when using a directory for /o!"); } catch (IOException) { // Success } finally { Directory.Delete(tempName); } }
public void ExecuteArgumentsTest() { int procID = TestEnvironment.testProcessInfo.ProcessId; string fileName = Path.GetTempFileName(); string[] args = new string[] { "/p", procID.ToString(), "/s", "/o", fileName }; ArgumentExecuter target = new ArgumentExecuter(args); int expected = 0; int actual = target.ExecuteArguments(); bool success = false; using (StreamReader fileReader = new StreamReader(new FileStream(fileName, FileMode.Open))) { string stackString = fileReader.ReadToEnd(); success = TestEnvironment.MatchedPredictedStackTrace(stackString); } try { File.Delete(fileName); } catch (FileNotFoundException ex) { Debug.WriteLine(ex.ToString()); } if ((expected != actual) || !success) { Assert.Fail("Microsoft.Mse.Gui.ArgumentExecuter.ExecuteArguments failed."); } }
public void InvalidProcessIdTest() { ArgumentExecuter target = new ArgumentExecuter(new string[] { "/p", "0" }); int retValue = target.ExecuteArguments(); if (retValue != 1) { Assert.Fail("Invalid process Id test failed for process ID 0!"); } }
public void InvalidOutFileTest() { // Pass in an invalid file name and check that IOException is thrown ArgumentExecuter target = new ArgumentExecuter(new string[] { "/p", "/o", "???.txt" }); try { target.ExecuteArguments(); Assert.Fail("Invalid out file test failed for ???.txt!"); } catch (IOException) { // Success } }