I've used TypeMock to mock an API of ours which is still in development / work in progress.
I have a test assembly (which uses TypeMock) of similarly named classes which you instantiate, and call a method on (to being mocking of a particular namespace), then any code which targets the real API gets my mocked versions.
So far, so straightforward.
I have a question about MockAll, in terms of lifetime/scoping.
We have a GUI (which is also work in progress) that needs to be able to use either the real, or mock API, and to be able to switch between them at runtime for testing. This will continue during the development process.
I wasn't sure if we should modify the GUI so that it read a setting from a Config file (or something like that), and if mocking was specified in the setting it instaantiated my mock assemby and called the mocking begin method (and kept a reference alive to my mock assembly), or whether we would be better leaving the GUI unchanged and instead provide a small command line EXE which instantiates the mocked assembly/enables mocking and which the developer can choose to start or not before they begin testing the UI?
From a lifetime point of view, when you call MockAll (from a particular program thread), how long does mocking of that class stay in force? until the user restarts Windows? until the assembly which contains the mocked methods goes out of scope/destroyed when the parent process is destroyed? some other event?
My mock assembly implements IDisposable, and in the Dispose method it clears all mocks. The way I envisaged the assembly being used was that the GUI would instantiate my mocked assembly, and then keep a member variable alive, and finally call dispose to switch mocking off.
If somebofy could clarify these issues that would be most helpful.
-Alastair