How do I pass dependency to object with Castle Windsor and MS Test?
- by Nick
I am trying to use Castle Windsor with MS Test. The test class only seems to use the default constructor. How do I configure Castle to resolve the service in the constructor?
Here is the Test Class' constructors:
private readonly IWebBrowser _browser;
public DepressionSummaryTests()
{
}
public DepressionSummaryTests(IWebBrowser browser)
{
_browser = browser;
}
My component in the app config looks like so:
<castle>
<components>
<component id="browser"
service="ConversationSummary.IWebBrowser, ConversationSummary"
type="ConversationSummary.Browser" />
</components>
</castle>
Here is my application container:
public class ApplicationContainer : WindsorContainer
{
private static IWindsorContainer container;
static ApplicationContainer()
{
container = new WindsorContainer(new XmlInterpreter(new ConfigResource("castle")));
}
private static IWindsorContainer Container
{
get { return container; }
}
public static IWebBrowser Browser
{
get { return (IWebBrowser) Container.Resolve("browser"); }
}
}
MS test requires the default constructor. What am I missing?
Thanks!