Contents

Contents

Mock Implementing Multiple Interfaces

Contents

One of the recent tests I had, I had to deal with the fact that a dependency object injected into system under test object will be casted to some other interface (known to be implemented) and used. Moq has some documentation on it, but it was a bit misleading. QuickStart wiki showed an example below:

image
image
From example it is a bit difficult to see that once foo is marked As, it can be casted in production code to IDisposable. This is a very helpful feature in Moq.