main
 1using System;
 2using Machine.Specifications;
 3
 4namespace unit
 5{
 6    static public class AssertionExtensions
 7    {
 8        static public void should_not_be_null<T>(this T item)
 9        {
10            item.ShouldNotBeNull();
11        }
12
13        static public void should_be_an_instance_of<T>(this object actual)
14        {
15            actual.ShouldBeOfType(typeof (T));
16        }
17
18        static public void should_be_equal_to<T>(this T actual, T expected)
19        {
20            actual.ShouldEqual(expected);
21        }
22
23        static public void should_not_be_equal_to<T>(this T actual, T expected)
24        {
25            actual.ShouldNotEqual(expected);
26        }
27
28        static public void should_be_true(this bool actual)
29        {
30            actual.ShouldBeTrue();
31        }
32
33        static public void should_be_false(this bool actual)
34        {
35            actual.ShouldBeFalse();
36        }
37
38        static public void should_have_thrown<Exception>(this Action action) where Exception : System.Exception
39        {
40            try
41            {
42                action();
43                throw new System.Exception("Did not throw.");
44            }
45            catch (Exception e)
46            {
47                if (!e.GetType().Equals(typeof (Exception)))
48                {
49                    throw new System.Exception("Threw the wrong exception");
50                }
51            }
52        }
53    }
54}