Skip to content

Instantly share code, notes, and snippets.

@KevM
Created January 29, 2009 20:51
Show Gist options
  • Save KevM/54733 to your computer and use it in GitHub Desktop.
Save KevM/54733 to your computer and use it in GitHub Desktop.
[Test]
public void Structure_map_should_use_the_last_in_configuration_for_a_type()
{
var container = new Container(config => config.ForRequestedType<ILogger>().TheDefaultIsConcreteType<NullLogger>());
container.GetInstance<UsesLogging>().Logger.ShouldBeOfType<NullLogger>();
container.Configure(config => config.ForRequestedType<ILogger>().TheDefault.Is.ConstructedBy(s=>new Log4NetLogger(s.ParentType)));
container.GetInstance<UsesLogging>().Logger.ShouldBeOfType<Log4NetLogger>();
}
public class UsesLogging
{
public ILogger Logger { get; private set; }
public UsesLogging(ILogger logger)
{
Logger = logger;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment