|
From: Jim A. <JA...@th...> - 2003-11-12 17:04:13
|
I had a look at this today. SetupResult() does work, but as soon as you Expect() on the same property's setter, the mock's internal record of the property's expected signature is overwrittten (ie it expects the getter to be called with an argument). As I'm not that familiar with the internals of Method, Mock and co. I thought I would ask you lot for input before I fixed it. My feeling is that properties should be treated differently to methods (not necessarily at the public API level, but internally). Although properties are technically methods, they have, conceptually, two signatures. At the moment, NMock doesn't care whether it's invoking a getter or a setter (it even strips the "get_" and "set_" from the names), and that's essentially the problem - calls to "get_Foo" and "set_Foo" are just recorded as a call to "Foo". So unless anyone has a better idea, I'll extend ClassGenerator and Mock to treat properties differently. Jim Thoughtworks |---------+-----------------------------------------> | | Steve Freeman | | | <st...@m3...> | | | Sent by: | | | nmo...@li...| | | ceforge.net | | | | | | | | | 09/11/2003 11:53 | | | | |---------+-----------------------------------------> >------------------------------------------------------------------------------------------------------------------------------| | | | To: "Jeremy Dunck (6433)" <JD...@ib...> | | cc: "Nmock-General (E-mail)" <nmo...@li...> | | Subject: Re: [Nmock-general] Mock properties? | >------------------------------------------------------------------------------------------------------------------------------| Yep, it's a bug and there's already a test to prove it called SetAndGetPropertiesDoesNotWorkWithSetupReturn For now, could you use ExpectAndReturn() ? S. Jeremy Dunck (6433) wrote: > It's a 3rd-party binary. > > Fortunately, COM interop provides an interface when it generates the > wrapper class, so that was free. :) > > Unfortunately, now I'm getting a different error. > > I've whittled it down to a failing test. Perhaps I'm doing something > wrong, or perhaps we found a bug. :) > > Thanks for the feedback. ------------------------------------------------------- This SF.Net email sponsored by: ApacheCon 2003, 16-19 November in Las Vegas. Learn firsthand the latest developments in Apache, PHP, Perl, XML, Java, MySQL, WebDAV, and more! http://www.apachecon.com/ _______________________________________________ Nmock-general mailing list Nmo...@li... https://lists.sourceforge.net/lists/listinfo/nmock-general |