BDD - 动态更改 MVC3 中的 Ninject 绑定
我是 Ninject 的新手,我已经使用我自己的 NinjectDependencyResolver 类进行了设置,如下所示: http://www.shahnawazk.com/2010 /12/dependency-injection-in-aspnet-mvc-3.html
我正在尝试设置 BDD 跨进程模拟 ala Steve Sanderson 的帖子: http://blog.stevensanderson。 com/2010/03/09/deleporter-cross-process-code-injection-for-aspnet/
Steve 建议如下:
Deleporter.Run(() => {
var mockDateProvider = new Mock<IDateProvider>();
mockDateProvider.Setup(x => x.CurrentDate).Returns(dateToSimulate);
NinjectControllerFactoryUtils.TemporarilyReplaceBinding(mockDateProvider.Object);
})
我将如何实现TemporarilyReplaceBinding 以便我可以从 Spec 项目动态更改 MVC3 项目中的绑定?
I'm new to Ninject and I've set it up using my own NinjectDependencyResolver class as per:
http://www.shahnawazk.com/2010/12/dependency-injection-in-aspnet-mvc-3.html
I'm trying to setup BDD cross-process mocking ala Steve Sanderson's post here:
http://blog.stevensanderson.com/2010/03/09/deleporter-cross-process-code-injection-for-aspnet/
Steve suggests something like:
Deleporter.Run(() => {
var mockDateProvider = new Mock<IDateProvider>();
mockDateProvider.Setup(x => x.CurrentDate).Returns(dateToSimulate);
NinjectControllerFactoryUtils.TemporarilyReplaceBinding(mockDateProvider.Object);
})
How would I implement TemporarilyReplaceBinding so that I can dynamically change the binding in my MVC3 project from my Spec project?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是否有任何原因无法使用 Steve 的 NinjectControllerFactoryUtils 类(以及 TidyupUtils 类)在 GitHub 上?
Is there any reason why you cannot use Steve's implementation of the NinjectControllerFactoryUtils class (and the TidyupUtils class) in the WhatTimeIsIt project on GitHub?