Code generation tool to create C # adapter classes for unit testing?
I know I won't need this with Typemock, however, with something like MoQ, I need to use an adapter pattern to enable mocks to be generated across interfaces for code that I have no control over.
For example, TcpClient is a .NET class, so I am using an adapter pattern to enable mocking of this object, b / c I need the interface of this class. Then I create an ITcpClient interface, which can then be implemented through the TcpClientAdapter class, which is a regular implementation of the vanilla adapter pattern.
I'm looking for a tool to do this automatically (interface and adapter creation), I think there is somewhere in there? (or everyone just encodes them)
a source to share
"Replace any .NET method with its own delegate" - Moles
I am passing the code over to me, but visit Moles . This will allow you to poke fun at all static methods, you name it. It is not a code generator, but you, for example, will have to write code / return values, but you will not need to write adapter classes. Instead, you simply indicate what you want to override per test.
This is new and I have not personally used it, but from the video I have seen it seems promising. Especially for problem areas like static API or classes out of your control.
a source to share