Created
September 18, 2014 12:14
-
-
Save ianfnelson/287b94e1e565e3ee7137 to your computer and use it in GitHub Desktop.
Snippets for 2010 blog post "Testing IoC Registrations"
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
AutoMapper.Mapper.AssertConfigurationIsValid(); |
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
[ClassInitialize] | |
public static void MyClassInitialize(TestContext testContext) | |
{ | |
var guyWire = new GeneralGuyWire(); | |
guyWire.Wire(); | |
} | |
/// <summary> | |
/// Tests that the IoC container can resolve instances of each Controller. | |
/// | |
/// Assuming that constructor DI is used throughout the system, this will | |
/// indirectly test that all dependencies have been correctly registered. | |
/// </summary> | |
[TestMethod] | |
public void Wire_CanResolveAllControllers() | |
{ | |
Assembly | |
.GetAssembly(typeof(HomeController)) | |
.GetExportedTypes() | |
.Where(t => MvcContrib.ControllerExtensions.IsController(t)) | |
.ForEach(c => Assert.IsNotNull(ServiceLocator.Current.GetInstance(c))); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment