From: Levi K. <LKh...@th...> - 2004-11-17 00:18:18
|
Hi Owen, Here's an example, try adding this to MockTest class: [Test] public void CallOverloadedMethodsInDifferentOrder() { mock.Expect("myMethod", "foo"); mock.Expect("myMethod", 1); mock.Invoke("myMethod", 1); mock.Invoke("myMethod", "foo"); mock.Verify(); } This test fails with the latest code from CVS even though myMethod(string) = and myMethod(int) are deferent overloads and IMO shouldn't be subjected to = the same call sequence at least logically. Regards, - Levi Owen Rogers/Canada/ThoughtWorks@THOUGHTWORKS 11/12/2004 06:38 AM To Levi Khatskevitch <LKh...@th...>@THOUGHTWORKS=5FCOM cc Jim Arnold <JA...@th...>, nmo...@li... Subject Re: [Nmock-general] MethodSignature and friends > Recently I was thinking about resolving methods to the first expectation = 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:=20 AFAIK, this is how nmock is supposed to work. what problems are you=20 experiencing when you try to do this?=20 cheers,=20 owen.=20 --- R. Owen Rogers ThoughtWorks Technologies (India) Pvt Ltd. ThoughtWorks - Deliver with passion! ThoughtWorks is always looking for talented people who are passionate=20 about technology. To find out more about a career at ThoughtWorks go to=20 http://www.thoughtworks.com/career/.=20 Levi Khatskevitch <LKh...@th...>=20 Sent by: nmo...@li...=20 01/11/2004 21:47=20 =20 To: Jim Arnold <JA...@th...>=20 cc: nmo...@li..., (bcc: Owen=20 Rogers/Canada/ThoughtWorks)=20 Subject: Re: [Nmock-general] MethodSignature and friends 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.=20 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:=20 mock.Expect("Foo", new IsAnything()); // expect either overload=20 mock.Expect("Foo", (int)1); // expect Foo(int) overload=20 mock.Expect("Foo", (double)1.2); // expect Foo(double) overload=20 mock.Invoke("Foo", 2); // ok, resolved to the first expectation=20 mock.Invoke("Foo", 1.0); // fail, resolves to the third expectation and=20 thus should be 1.2=20 Any thoughts on this?=20 Regards,=20 - Levi=20 Jim Arnold <JA...@th...>=20 Sent by: nmo...@li...=20 11/01/2004 08:41 AM=20 To nmo...@li...=20 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 =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 =20 Can I get a +/- 1 from anybody?=20 =20 Jim=20 ------------------------------------------------------- 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 |