【发布时间】:2016-02-23 16:40:35
【问题描述】:
我正在尝试对 Orchestrator 进行单元测试。
//Arrange
var containter = new WindsorContainer();
var Orch = containter.Resolve<ApiOrchestrator>();// Exception Thrown here
Orchestrator 的构造函数是:
public ApiOrchestrator(IApiWrap[] apiWraps)
{
_apiWraps = apiWraps;
}
注册是
public class IocContainer : IWindsorInstaller
{
public void Install(IWindsorContainer container, IConfigurationStore store)
{
container.Register(Component.For<FrmDataEntry>().LifestyleTransient());
container.Register(Component.For<ApiOrchestrator>().LifestyleTransient());
container.Register(Component.For<IApiWrap>().ImplementedBy<ClassA>().LifestyleTransient());
container.Register(Component.For<IApiWrap>().ImplementedBy<ClassB>().LifestyleTransient());
}
}
IocContainer 在正在测试的项目中,但命名空间被引用,我可以new 使用 Orchestrator。我希望它只给我所有注册的 IApiWrap 的数组。
刚接触 Castle,我不明白缺少什么。代码修复会很好,但我真的很想知道为什么容器似乎没有注册协调器。
【问题讨论】:
-
所以我认为我错过了从容器中调用 install 方法,但我不确定将什么用作 IWindsorInstaller
标签: inversion-of-control castle-windsor ioc-container castle