|
From: Steve F. <st...@m3...> - 2003-11-09 11:53:27
|
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. |
|
From: Jeremy D. (6433) <JD...@ib...> - 2003-11-09 20:36:39
|
Arg. Sorry to waste your time. :( Thanks for the help. > -----Original Message----- > From: Steve Freeman [mailto:st...@m3...] > Sent: Sunday, November 09, 2003 5:53 AM > To: Jeremy Dunck (6433) > Cc: Nmock-General (E-mail) > 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. > |
|
From: Steve F. <st...@m3...> - 2003-11-09 22:10:48
|
No problem. It's a good reminder that we should fix it (or you could ;-) S. Jeremy Dunck (6433) wrote: > Arg. Sorry to waste your time. :( > > Thanks for the help. > |
|
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 |
|
From: Joe W. <jo...@th...> - 2003-11-12 17:51:49
|
Sounds good to me. -joe Jim Arnold wrote: > > >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 > > > > > > |
|
From: Mike B. <mbr...@vi...> - 2003-11-14 02:09:21
|
Does NMock not work with properties (yet)? I'm new to NMock (and C#) and am
having trouble with the following code where I try to set a property to an
expected value. When I access the property I get a null. I had been
assuming this was my own fault until I read the attached message in the
mailing list archive.
public interface IRegistry {
// This property is causing me troubles.
IRegistryKey LocalMachine { get; }
}
public interface IRegistryKey {
IRegistryKey OpenSubKey( string name);
string[] GetSubKeyNames();
object GetValue( string name);
}
public class RegistryFacade {
private IRegistry registry;
public RegistryFacade( IRegistry registry) {
this.registry = registry;
}
public InstalledJDK[] getInstalledJDKs() {
// This throws an null reference exception, because LocalMachine
is null.
IRegistryKey jdkKey = registry.LocalMachine.OpenSubKey("foo");
}
}
[NUnit.Framework.TestFixture]
public class TestRegistryFacade {
[NUnit.Framework.Test]
public void test02() {
NMock.IMock registry = new NMock.DynamicMock( typeof( IRegistry));
NMock.IMock localMachine = new NMock.DynamicMock( typeof(
IRegistryKey));
registry.ExpectAndReturn("get_LocalMachine",
(IRegistryKey)localMachine.MockInstance);
RegistryFacade facade = new RegistryFacade(
(IRegistry)registry.MockInstance);
InstalledJDK[] installedJdks = facade.getInstalledJDKs();
}
}
Mike
-----
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
|