i discovered a fun little bug in nmock yesterday. i noticed that i was receiving a strange verify exception that was occurring outside of my tests. the exception reported that the Finalize() method was getting called too many times. incidentally, Finalize() is the class destructor -- it is what the ~Class() method gets turned into by the C# compiler. Finalize() is a virtual method, so it was getting overriden by the mock proxy. when the garbage collector went to dispose of the proxy, a verify exception was thrown because i hadn't set up an expectation for my destructor :). note: this is only a problem if you are generating a mock from a concrete class and setting the mock to strict.
to fix the problem, i have ammended the mock class so that it doesn't override the destructor -- i can't imagine why you would want to mock your class' destructor as it is typically something that you don't call directly. it also feels a little bit disconcerting to override the destructor for a base class which might actually be doing something important.