Modified:
/trunk/TinyBDD.Specification.NUnit/SpecificationExtensions.cs
/trunk/TinyBDD.Specification.NUnitTests/ShouldThrowExceptionSpecs.cs
=======================================
--- /trunk/TinyBDD.Specification.NUnit/SpecificationExtensions.cs Wed Oct
7 06:51:05 2009
+++ /trunk/TinyBDD.Specification.NUnit/SpecificationExtensions.cs Tue Nov
3 14:58:37 2009
@@ -108,13 +108,22 @@
{
Assert.Greater(list.Count, expectedCount);
}
+
+ public static void ShouldThrowException<T>(this object anObj,
Action action) where T : Exception
+ {
+ ShouldThrowException<T>(action, ex => { });
+ }
public static void ShouldThrowException<T>(this object anObj,
Action action, Action<T> exception) where T : Exception
+ {
+ ShouldThrowException<T>(action, exception);
+ }
+
+ private static void ShouldThrowException<T>(Action action,
Action<T> exception) where T : Exception
{
ShouldThrowExceptionTemplate<T> template = new
ShouldThrowExceptionTemplate<T>(
() => action.Invoke(), m => Assert.Fail(m), exception);
template.Execute();
-
}
}
}
=======================================
--- /trunk/TinyBDD.Specification.NUnitTests/ShouldThrowExceptionSpecs.cs
Tue Nov 3 14:28:09 2009
+++ /trunk/TinyBDD.Specification.NUnitTests/ShouldThrowExceptionSpecs.cs
Tue Nov 3 14:58:37 2009
@@ -11,6 +11,12 @@
[TestFixture]
public class ShouldThrowExceptionSpecs
{
+ [Test]
+ public void Should_be_able_to_use_simple_specificaiton()
+ {
+ this.ShouldThrowException<ArgumentNullException>(() => { throw
new ArgumentNullException(); });
+ }
+
[Test]
public void
Should_throw_AssertionException_if_specified_exception_is_not_thrown()
{