最小起订量的可链接实施
是否有可链接的 Moq 实现?我在想,而不是这样:
var mockSchedule = new Mock<Schedule>();
mockSchedule.SetupGet(x => x.Date).Returns(new DateTime(2011,6,1));
mockSchedule.SetupGet(x => x.Label).Returns("Schedule A");
我可以这样称呼它:
var mockSchedule =
new Mock<Schedule>()
.Which().SetupGet(x => x.Date).Returns(new DateTime(2011,6,1))
.Which().SetupGet(x => x.Label).Returns("Schedule A");
或者这样:
var mockSchedule =
new Mock<Schedule>().
.SetupGetWith(x => x.Date,new DateTime(2011,6,1))
.SetupGetWith(x => x.Label,"Schedule A");
我可以自己编写这些,但如果有现有的实现,我宁愿不重新发明轮子
Is there a chainable implementation of Moq out there? I was thinking that instead of this:
var mockSchedule = new Mock<Schedule>();
mockSchedule.SetupGet(x => x.Date).Returns(new DateTime(2011,6,1));
mockSchedule.SetupGet(x => x.Label).Returns("Schedule A");
I can call it like this:
var mockSchedule =
new Mock<Schedule>()
.Which().SetupGet(x => x.Date).Returns(new DateTime(2011,6,1))
.Which().SetupGet(x => x.Label).Returns("Schedule A");
or like this:
var mockSchedule =
new Mock<Schedule>().
.SetupGetWith(x => x.Date,new DateTime(2011,6,1))
.SetupGetWith(x => x.Label,"Schedule A");
I could write these myself but if there's an existing implementation I'd rather not reinvent the wheel
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
有点;有 Moq v4 功能规格。
文档可能会更好。我的博客上有一篇简短的文章。另请参阅旧式命令式模拟与 moq 功能规范 和 此起订量讨论主题。
Sort of; there's the Moq v4 functional specifications.
The documentation could be better. I've got a short writeup on my blog. See also Old style imperative mocks vs moq functional specifications and this Moq Discussions thread.