Created
January 17, 2011 23:06
-
-
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 :-)
This file contains hidden or 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; | |
| 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