"Thirty Days of TDD Day 12: working with stubs"
www.telerik.com/blogs/30-days-of-tdd-day-12-working-with-stubs
I already have a couple of Mocking frameworks installed and I'm sure JustMock is great but my registry is messed up enough already so
I thought I'd translate to Moq and see how I went.
Wehn I try to run the tests I can the very obscure error
Error 2 Argument 1: cannot convert from 'Moq.Mock
apparently this is a fairly common Moq beginner error and posting the error here in case it will save somebody a few minutes
var orderDataService = new Mock
orderDataService.Setup(x => x.Save(It.IsAny
var orderService = new OrderService(orderDataService);
and instead it should be
var orderService = new OrderService(orderDataService.Object);
As always Stack Overlow saved the day, once I figured out how to word a search
http://stackoverflow.com/questions/7011572/passing-moq-mock-objects-to-constructor
1 comment:
Thanks for posting the solution .I struggled for an hour and finally your solution helped .
Post a Comment