|
From: Levi K. <LKh...@th...> - 2004-11-01 16:16:36
|
I had the same idea a while ago, but how would you handle argument=20
constraints like NotNull() that do not specify the argument type? Losing=20
them will make expectations more verbose but on the other hand requiring=20
too precise expectations often results in unit tests that follow real code =
too closely - a common problem with interaction base testing that I've=20
seen.
Recently I was thinking about resolving methods to the first expectation=20
in the call sequence where argument types match. This preserves the=20
flexibility but also supports overloading in a more consistent way. For=20
example:
mock.Expect("Foo", new IsAnything()); // expect either overload
mock.Expect("Foo", (int)1); // expect Foo(int) overload
mock.Expect("Foo", (double)1.2); // expect Foo(double) overload
mock.Invoke("Foo", 2); // ok, resolved to the first expectation
mock.Invoke("Foo", 1.0); // fail, resolves to the third expectation and=20
thus should be 1.2
Any thoughts on this?
Regards,
- Levi
Jim Arnold <JA...@th...>=20
Sent by: nmo...@li...
11/01/2004 08:41 AM
To
nmo...@li...
cc
Subject
[Nmock-general] MethodSignature and friends
The method resolution in NMock is really starting to annoy me :-) It=20
works for simple cases (find a method named "Foo" with a return type of=20
"Bar"), but complex scenarios with overloads and indexed properties are=20
still buggy. The fundamental problem is that the user is not forced to=20
specify the attributes necessary to find a method. SetupResult() can just =
take a method name and a return value, which is really not enough to=20
resolve overloaded properties.
=20
We should just get rid of the whole MethodSignature thing and start using=20
real MethodInfos and PropertyInfos instead. It might make the public API=20
slightly more complex, but would close a whole class of bugs.
=20
Can I get a +/- 1 from anybody?
=20
Jim
------------------------------------------------------- This SF.Net email=20
is sponsored by: Sybase ASE Linux Express Edition - download now for FREE=20
LinuxWorld Reader's Choice Award Winner for best database on Linux.=20
http://ads.osdn.com/?ad=5FidU88&alloc=5Fid=12065&op=3Dclick=20
=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=
=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F=5F Nmock-ge=
neral mailing list=20
Nmo...@li...=20
https://lists.sourceforge.net/lists/listinfo/nmock-general=20
|