Skip to content

Instantly share code, notes, and snippets.

@agross
Created January 24, 2013 14:17
Show Gist options
  • Save agross/4622142 to your computer and use it in GitHub Desktop.
Save agross/4622142 to your computer and use it in GitHub Desktop.
using System;
using Machine.Specifications;
namespace ns
{
[Behaviors]
public class BazBaz<TException>
where TException : Exception
{
protected static Exception ExpectedException;
It should_be_of_expected_type_gen = () => ExpectedException.ShouldBeOfType<TException>();
It should_throw_an_exception_gen = () => ExpectedException.ShouldNotBeNull();
It should_throw_an_exception_gen_2 = () => ExpectedException.ShouldNotBeNull();
}
[Behaviors]
public class TestTest
{
protected static Exception ExpectedException;
It should_be_of_expected_type = () => ExpectedException.ShouldBeOfType<Exception>();
It should_throw_an_exception = () => ExpectedException.ShouldNotBeNull();
}
[Subject("foo")]
public class When_an_exception_is_thrown
{
protected static Exception ExpectedException;
Establish context = () => { };
Because of = () => { ExpectedException = Catch.Exception(() => { throw new Exception(); }); };
Behaves_like<BazBaz<Exception>> bg_1;
Behaves_like<BazBaz<InvalidOperationException>> bg_2;
Behaves_like<BazBaz<BarBar>> bg_3;
Behaves_like<BazBaz<BarBar>> bg_4;
Behaves_like<TestTest> b_1;
Behaves_like<TestTest> b_2;
Behaves_like<TestTest> b_3;
It should;
It should_2;
It should_3;
}
class BarBar : Exception
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment