English 中文(简体)
IOC (simpleserviceLocator) 安装测试
原标题:IOC (simpleServiceLocator) setup testing with Specflow and WatiN

我有一些使用Specflow和WatiN的验收测试,但无法确定在什么地方为我的IOC集装箱(SimpleserviceLocator)建立我的登记。

In my web site, the registration is done my global.asax.

在我的测试项目中,我曾尝试从我的[BeforeScenario]方法中确定这些方法,其代码如法典。

var container = new SimpleServiceLocator();
container.Register<ISitecoreLookupAccessor>(
    () => new SitecoreLookupAccessor());

Microsoft.Practices.ServiceLocation.ServiceLocator
    .SetLocatorProvider(() => container);

And I get an object instance in my application project using

ISitecoreLookupAccessor accessor =
    ServiceLocator.Current.GetInstance<ISitecoreLookupAccessor>();

但是,我有了一个错误,即“物体不是指作为服务对象的物体”。 现任法官

问题回答




相关问题
Validate interface using IoC

I have a domain model that uses IoC with Microsoft Unity. For the validation I use VAB and I decorate the interface, not the entity. The code the following: interface IJob : IValidable { [...

Injecting Subsonic SimpleRepository class to controller

I m tryingot get started with IoC, I have an MVC project in which is use subsonic, I m trying to inject subsonic simplerepository to my controllers but I m getting this error: StructureMap Exception ...

Unity view Registered Types during debug

Possibly a stupid question, but during debug I simply want to see the types that have been registered with my Unity container. I have tried going through the container in the watch window, but can t ...

ASP.NET MVP Injecting Service Dependency

I have an ASP.NET page that implements my view and creates the presenter in the page constuctor. Phil Haack s post providing was used as the starting point, and I ll just the examples from the post ...

Unity Container Disposing and XML Web Service

I am registering some wrapers over un-managed objects in container. How can I dispose of them at the end of the container s lifetime? Please bear in mind I have an XML Web service.

热门标签