Rocks icon indicating copy to clipboard operation
Rocks copied to clipboard

Consider Making `Expectations` to be Disposable

Open JasonBock opened this issue 2 years ago • 5 comments

I just make RockRepository implement IDisposable "better", in that once Dispose() is called, you can't call members on it again without getting ObjectDisposedException.

I'm starting to wonder if Expectations<T> should do the same thing. In other words, make Dispose() do what Verify() does, enforce dispose semantics, and then remove Verify().

This would be a pretty big change, because I'm removing a member that used all over the place. But....it feels like this might be a better design. Definitely need to think this one through.

JasonBock avatar Mar 30 '23 01:03 JasonBock

I would consider doing this if I go down this road.

JasonBock avatar Aug 11 '23 18:08 JasonBock

Definitely considering doing this now.

JasonBock avatar Sep 03 '23 20:09 JasonBock

Since RockRepository was deleted with 8.0.0, it may make sense to revisit this and see if it makes sense. I know when I tried it recently, there were test cases that ended up being a little awkward by doing this, but....worth another shot.

JasonBock avatar Jan 13 '24 15:01 JasonBock

Note: I would put XML docs on Verify() that people should stop calling it, and move to handling the expectations objects as a disposable one. Eventually, I'd obsolete it, but not for the moment. Maybe have to put some defensiveness in both Verify() and Dispose() to not do it twice.

JasonBock avatar May 11 '24 19:05 JasonBock

One idea is that Dispose() would only be concerned about any potential clean-up, like for SAMIs. It would not do the Verify() call for you, unless you haven't done it yet.

JasonBock avatar Jul 30 '24 13:07 JasonBock