|
From: Paul B. <Pau...@vi...> - 2004-07-06 16:16:29
|
It's not so much a problem as a possible inconvinience at times. I = think my sample below didn't properly set up the situation. Let's say = that I have method X that I want to test, but to get to the right state, = I have to call methods A, B, C, D, and E, each of which result in calls = to the Mock object. It would be easier for me to not have to worry = about counting the various method calls in that setup stage. If I could = wipe out my expectations, then I would only have to check the stuff that = goes along with method X. So there's nothing wrong with calling Verify = multiple times, but I'd like not to have to think about verifying the = results of methods A-E (say, because I've already verified that they = work elsewhere). =20 =20 It's ultimately just a matter of convinience. =20 Thanks! =20 =20 -----Original Message----- From: Owen Rogers [mailto:OR...@th...] Sent: Saturday, July 03, 2004 3:37 AM To: Paul Brousseau Cc: nmo...@li... Subject: Re: NMock hi paul,=20 what sort of problem do you receive from nmock when you try to do this? = AFAIK, there is nothing stopping you from calling Verify as many times = as you like. why is it important to reset the expectations? is there = any problem with just accumulating them until the end of the test?=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 = about technology. To find out more about a career at ThoughtWorks go to = http://www.thoughtworks.com/career/.=20 "Paul Brousseau" <Pau...@vi...>=20 03/07/2004 00:03=20 =20 To: <jo...@th...>, = <cst...@th...>, <or...@th...>=20 cc: =20 Subject: NMock Hello! I'm using NMock for a project, and I need it to do something = that it doesn't appear to do at the moment. I would like to be able to set up a dynamic mock and do several tests = with it in a row, resetting the expectactions each time. A stripped = down example: mockPageView.Expect("ZoomToFullPage"); controller.UndoZoom(); // Do assertions of zoom depth. mockPageView.Verify(); mockPageView.Expect("ZoomToRectangle"); controller.ZoomToRectangle(new RectangleF(0, 0, 5f, 5f)); // Do assertions of zoom depth. mockPageView.Verify(); mockPageView.Expect("ZoomToFullPage"); controller.UndoZoom(); // Do assertions of zoom depth. mockPageView.Verify(); mockPageView.Expect("ZoomToRectangle"); mockPageView.Expect("ZoomToFullPage"); controller.ZoomToRectangle(new RectangleF(0, 0, 5f, 5f)); controller.ZoomToFullPage(); // Do assertions of zoom depth. mockPageView.Verify(); This would all be in one logical unit test, as I'm interested in = verifying a certain sequence of events (and related properties), but I = want to make sure everything is going as planned along the way. I would = like Verify to clear the expectactions, OR make an explicit call to = clear them. I didn't see anything like this on the roadmap. Are there plans? If = not, does this seem like the kind of thing that a reasonably clever = engineer (myself) could hack up in day, without having previous = expirience with the source? And if so, would you accept a contribution = back? Thanks! |