How to forward to another object when using .NET Moq?
问题 Given an object, I would like to create a mock that implements the interface of the object and mocks one method, but forwards the rest of the methods to the real object, not the base class . For example: ISqlUtil sqlUtil = GetTheRealSqlUtilObjectSomehow(...); var mock = new Mock<ISqlUtil>(); mock.Setup(o => o.SpecialMethodToBeMocked(...)).Returns<...>(...) // Here I would like to delegate the rest of the methods to the real sqlUtil object. How ? So, in the example I want to mock just ISqlUtil