#1651·moq

wrap an existing instance of an interface

Author: jpribeleCreated Jan 14, 2026Updated Jun 24, 2026
Labelsenhancement

What I want to do put a mock around around existing instance so I that I verify that the methods are called

IFoo foo = GetFoo(); var mock = new Mock( foo ); mock.Setup(....)

The only way I can see to this is to implement IFoo myself that wraps the foo instance and then do new Mock(foo)

is there some other way to do this?

Back this issue Back this issue