main
1using System;
2using System.Collections.Generic;
3using NUnit.Framework;
4using tests.unit;
5
6public delegate void it();
7
8public delegate void because();
9
10public delegate void context();
11
12public delegate void after_all();
13
14namespace tests
15{
16 public abstract class test
17 {
18 IDictionary<string, it> tests = new Dictionary<string, it>();
19 static public IMockFactory mock_factory = new RhinoMockFactory();
20
21 [TestFixtureSetUp]
22 public virtual void initialize()
23 {
24 context();
25 because();
26 Console.Out.WriteLine();
27 Console.Out.WriteLine(GetType().Name);
28 }
29
30 [Test]
31 public void output()
32 {
33 GetType().run_all<it>(this);
34 tests.each(test => test.run());
35 GetType().run_single<after_all>(this);
36 }
37
38 protected void it(string should, it test)
39 {
40 tests[should] = test;
41 }
42
43 protected virtual void context()
44 {
45 GetType().run_stacked<context>(this);
46 }
47
48 protected virtual void because()
49 {
50 GetType().run_stacked<because>(this);
51 }
52
53 static protected T an<T>() where T : class
54 {
55 return mock_factory.create<T>();
56 }
57
58 static protected T dependency<T>() where T : class
59 {
60 return mock_factory.create<T>();
61 }
62 }
63}