Tuesday, May 04, 2010

Rhino Expectations should be hit but aren't

I was writing a unit test for a method implemented as a linq query returning IEnumerable and using RhinoMocks to stub out a dependency. Despite all my best debugging efforts where it appeared obvious that the expectations I set should have been met, VerifyAll was throwing with Expected #1 Actual #0.

After lots of head scratching I realized that it's because when calling VerifyAll, nothing had yet enumerated the result of the method call. Linq's laziness had prevented my code from running and therefore meeting my expectations.

After further head scratching, it turns out I've already hit the same problem once before and blogged about it here, so I'm just going to leave this up as a reminder to read your own blog.

1 comment:

paul smith said...

nice post