When Rhino Attacks - This action is invalid when the mock object is in verified state.

by jfisch 15. May 2009 09:43

I'm just ramping up on Rhino Mocks and I've begun beating my head against what appears to be a common issue experienced by fellow Rhinoers.  Some test-driven developers have had the misfortune of having the disease go "south" into their testees.  To avoid this painful symptom I've decided to put together an attempt at a comprehensive list of When Rhino Attacks - This action is invalid when the mock object is in verified state.

From my reading, the problem seems to stem from various sources of Dispose being called on your mock object after your object has already been verified.  Although, I'm new enough to Rhino Mocks that I have to be honset and I'm not completeyl sure how this manifests and how the Rhino Mocks model runs into this issue.  However, there seems to be a number of common solutions to this problem which should be of asisstance.

Ydie's IDisposable solution seems to work for cases where you feel the need to dispose of your mock object explicitly.

Xerxes ExternalDataComponent solution seems to work for cases where you need to utilize ExternalDataComponent.

However, in my case it was caused by a necessary database object instance being used within a Visual Studio codegen class.  The test was trying to use a previous static containing a database object that had affectively "expired".

In case you had the neat idea of just adding this exception to the expected exceptions for your test, please rethink your solution.

Ciao!

Jeff Fischer

Tags: , , , , ,

Rhino Mocks

Comments

2/5/2012 8:53:37 AM #

Kelly Orpen

hmm good to know

Kelly Orpen United States

2/5/2012 8:53:47 AM #

Raylene Houp

Hey There. I discovered your webpage seeking with yahoo. That is an extremely effectively penned content. I will be sure you bookmark it and return to study even more of the beneficial info. Thank  you for sharing it. I will definitely be back again once more.

Raylene Houp United States

2/5/2012 8:55:10 AM #

Rosalyn Adas

check here as well: http://www.space-outpost/sci-fi/

Rosalyn Adas United States

2/5/2012 9:00:21 AM #

Joella Spirko

check here as well: http://www.space-outpost/sci-fi/

Joella Spirko United States

2/5/2012 9:02:39 AM #

web marketing master

Hi this is a good write-up. I'm going to mail this to my pals. I came on this while exploring on aol I'll be sure to come back. thanks for sharing.

web marketing master United States

2/5/2012 9:07:41 AM #

Mikel Sprain

that is really interesting...

Mikel Sprain United States

2/5/2012 9:09:20 AM #

 propan

ooo super

propan United States

2/5/2012 9:12:40 AM #

Sophia Ross

I don't think much of a man who is not wiser today than he was yesterday. - Abraham Lincoln

Sophia Ross United States

2/5/2012 9:22:48 AM #

Gilma Hoerl

check here as well: http://www.space-outpost/sci-fi/

Gilma Hoerl United States

2/5/2012 9:26:55 AM #

Eula Sampselle

hmm really interesting...

Eula Sampselle United States

2/5/2012 9:35:16 AM #

Armand Rentz

check here as well: http://www.space-outpost/sci-fi/

Armand Rentz United States

2/5/2012 9:39:35 AM #

Theola Congdon

I´ve really like reading this post. You use a lot of effort to writting it and that´s cool! Cheers!

Theola Congdon United States

2/5/2012 9:42:53 AM #

duplicate files finder

[...] Wonderful story, reckoned we could combine a few unrelated data, nevertheless really worth taking a look, whoa did one learn about Mid East has got more problerms as well  [...]a€|

duplicate files finder United States

Add comment


(Will show your Gravatar icon)

  Country flag

biuquote
  • Comment
  • Preview
Loading



Powered by BlogEngine.NET 1.5.0.7
Theme by Mads Kristensen