We are mocking an interface which includes an int property with both get and set accessors:
In most cases, nMock's ClassGenerator.Generate() produces correct code, a single MaxParasToScan property with both a getter and a setter. But in some environments, it generates code as in the file BadMockIVwRootBox.cs, which I will attempt to attach, where there are two MaxParasToScan properties, one with a getter and one with a setter. This does not compile, causing spurious test failures.
We are having this problem with Visual Studio 2008, on both Vista and Windows XP. We did not experience it with VS 2005. We are using only DotNet 2.0 at this point. We are running nunit 2.4.7.
So far, the problem occurs on only some computers, and in only some situations. It never occurs while debugging under Visual Studio, but (on the problem computers) always happens when we run tests in batch mode, or when we run nunit.exe directly from a command line or by double-clicking it. Most strangely, when we launch nunit.exe manually, and then attach the VS debugger to the process, we observe that the tests fail if they are run before we attach the debugger, but succeed once the debugger is attached.
Hypothesis: the problem may be related to the fact that Type.GetMembers() is not guaranteed to produce members in any particular order; is it possible that nMock depends on get_MaxParasToScan() being generated adjacent to set_MaxParasToScan(), and that this usually but not always happens?