Created
May 8, 2012 04:09
-
-
Save derans/2632505 to your computer and use it in GitHub Desktop.
Default Instance Tester
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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