c# - How to make a unit test mock of an object with non-virtual functions -
I have a C # class that is generated using the wsdl.exe tool that looks something like this: / P>
Public partial class soap: System. Web. Services. Protocol. Soap HP Client Protocol {Public Soap Type Enam Asking Questions () {Object [] Results = Come back to it. ("AskServerQuestion Ask"); Return (SOAPTypeEnum) result [0]; }}
There is some thin wrapper code around me which monitors the result etc. Is it possible to use any object to make fake sapphire squares and make fun of the frameworks? The result of each call for thin wrapper works?
I can not make the AskServerQuestion () function virtual because it is automatically generated by the wsdl.exe tool.
The way I completed it, instead of injecting an ISOAPAP, where the ISOAPAP interface is automatically The generated SOP imitates the API.
For your case:
Public Interface ISOPAP {SOAPTypeEnum AskServerQuestion (); }
Then, take advantage of the fact that the generated Soappy class is partial, and add it to another file:
Public partial class SOAP: ISoapApi {}
Then, consumers should only take an ISOPP dependency which can be joking through any joke frameworks.
One downside, when the SOAP API changes, you also have to update your interface definition.
Comments
Post a Comment