Skip to content

Instantly share code, notes, and snippets.

@mausch
Created September 26, 2009 22:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mausch/194468 to your computer and use it in GitHub Desktop.
Save mausch/194468 to your computer and use it in GitHub Desktop.
[TestFixture]
public class IIRFTests {
[Test]
[Factory("IIRFTestFactory")]
public void IIRFTest(string orig, string dest) {
File.WriteAllText(@"SampleUrls.txt", string.Format("{0}\t{1}", orig, dest));
var r = RunProcess(@"TestDriver.exe", @"-d .");
if (r.ErrorLevel != 0) {
var actual = Regex.Replace(r.Output.Replace("\r\n", " "), @".*actual\((.*)\).*", "$1");
Assert.AreEqual(dest, actual);
}
}
public IEnumerable<object[]> IIRFTestFactory() {
yield return new object[] { "/questions/167586/visual-studio-database-project-designers", "/Question/Index.aspx?id=167586" };
yield return new object[] { "/users/21239/mauricio-scheffer", "/User/Index.aspx?id=21239" };
}
public ProcessOutput RunProcess(string fileName, string arguments) {
var p = Process.Start(new ProcessStartInfo(fileName, arguments) {
CreateNoWindow = true,
RedirectStandardOutput = true,
RedirectStandardError = true,
UseShellExecute = false,
});
p.WaitForExit();
return new ProcessOutput(p.ExitCode, p.StandardOutput.ReadToEnd() + p.StandardError.ReadToEnd());
}
public class ProcessOutput {
public int ErrorLevel { get; private set; }
public string Output { get; private set; }
public ProcessOutput(int errorLevel, string output) {
ErrorLevel = errorLevel;
Output = output;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment