Skip to content

Instantly share code, notes, and snippets.

@ashmoran
Created January 17, 2011 23:06
Show Gist options
  • Select an option

  • Save ashmoran/783670 to your computer and use it in GitHub Desktop.

Select an option

Save ashmoran/783670 to your computer and use it in GitHub Desktop.
Highly WIP, I'm test-driving a test framework in a language I don't know :-)
using System;
namespace CSharpTestFramework
{
class MainClass
{
private uint run;
private uint failures;
delegate void Test();
class TestGroup
{
public string Status()
{
return "";
}
}
private void RunTest(Test test)
{
run++;
try {
test();
} catch (Exception ex) {
failures++;
}
}
private void RunPassingTest()
{
RunTest(() => { });
}
private void RunFailingTest()
{
RunTest(() => { throw new Exception(); });
}
public void Run()
{
RunPassingTest();
RunPassingTest();
RunFailingTest();
RunTest(
() => {
var testGroup = new TestGroup();
if(testGroup.Status() != "0 run, 0 failures")
throw new Exception();
}
);
Console.WriteLine(String.Format("{0} run, {1} failures", run, failures));
}
public static void Main (string[] args)
{
MainClass main = new MainClass();
main.Run();
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment