Showing posts with label rhinomocks. Show all posts
Showing posts with label rhinomocks. Show all posts

Thursday, July 8, 2010

RhinoMocks and InternalsVisibleTo

Well, when I first found this tip, I thought the name DynamicProxyGenAssembly2 was, you know, like a placeholder for my assembly name. But no, it actually means exactly what it says. This is the full explanation.

Wednesday, June 16, 2010

RhinoMocks - Method Signature & Null Reference Exception

OK, so it took me a while to figure this one out...

I would compile my project, would work fine, but when I ran the test, I would get "Object reference not set to the instance of an object" exception. I thought for the longest time it was my Mock object, but it wasn't.

The cause was because my method signature that I was stubbing was different than what I defined in my stub. So reflection couldn't find the method I was telling Rhino to stub.

Another interesting tidbit, the way I arranged my Given statements, I set an expectation on a Repository that method Get(int) would be called, then later in the Given I set the value of int. The mock was not prepared to handle "any" int, but only the one I set with the Expectation. Once I moved the assignment of int above the Mock Repository, it worked as expected.

As a side note, the order of the Given statements in the Feature determine the order the methods in the Spec are run. Interesting...