Skip to content

Instantly share code, notes, and snippets.

@derans
Created May 8, 2012 04:09
Show Gist options
  • Save derans/2632505 to your computer and use it in GitHub Desktop.
Save derans/2632505 to your computer and use it in GitHub Desktop.
Default Instance Tester
[TestFixture]
public class ControllerTester : TestBase
{
private IEnumerable<Type> ControllerTypes
{
get
{
var assembly = Assembly.GetAssembly(typeof(HomeController));
return assembly.GetTypes()
.Where(controller => controller.IsSubclassOf(typeof(Controller))
&& !controller.IsAbstract);
}
}
[Test, TestCaseSource("ControllerTypes")]
public void All_Controllers_should_have_a_default_instance(Type controllerType)
{
var instance = ObjectFactory.GetInstance(controllerType);
instance.ShouldNotBeNull();
instance.ShouldBeType(controllerType);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment