Mocking objects with Moq when constructor has parameters
Change the last line to var syncEngine = new Mock<CustomerSyncEngine>(mockLogger, mockCrm, mockCache).Object; and it should work
Change the last line to var syncEngine = new Mock<CustomerSyncEngine>(mockLogger, mockCrm, mockCache).Object; and it should work
In short, AutoFixture.AutoMoq is an extension that turns AutoFixture into an Auto-Mocking Container using the Moq dynamic mock library. There’s also a similar extension for AutoFixture that enables auto-mocking with Rhino Mocks. This article introduces auto-mocking for AutoFixture: http://blog.ploeh.dk/2010/08/19/AutoFixtureAsAnAutomockingContainer.aspx. Here’s a couple of follow-ups: http://blog.ploeh.dk/2010/08/25/ChangingTheBehaviorOfAutoFixtureAutomockingWithMoq.aspx http://blog.ploeh.dk/2010/11/13/RhinoMocksbasedAutomockingWithAutoFixture.aspx
Setup() can be used for mocking a method or a property. SetupGet() is specifically for mocking the getter of a property. Took a quick peek at the Moq source code and it looks like if you use Setup() on a property getter, it will call SetupGet(). So in that case, it is probably more personal … Read more
This is called a partial mock, and the way I know to do it in Moq requires mocking the class rather than the interface and then setting the “Callbase” property on your mocked object to “true”. This will require making all the methods and properties of the class you are testing virtual. Assuming this isn’t … Read more
ADDENDUM: As the other answer states, the purpose of .Verifiable is to enlist a Setup into a set of “deferred Verify(…) calls” which can then be triggered via mock.Verify(). The OP’s clarification makes it clear that this was the goal and the only problem was figuring out why it wasn’t working, but as @Liam prodded, … Read more