Hi Neil,
Interesting case :). The root cause for this lies in a limitation Isolator has, not being able to record field access. The culprit here is not B, but rather A - A.C is a field, and as such the access to it is not recorded in the WhenCalled() statement. Here's where things get interesting and two negatives balance each other out. The short story - turning C into a property (and allowing it to be recorded) sets everything aright. The full story is below.
What happens in the first case (where A is a field) is that out of the entire b.A.C.ReturnInt() chain, b.A and A.C are field accesses, so only C.ReturnInt() was recorded. C is a valid object (it was constructed with A), so the recording succeeds. In the second case (where A is a property) the case is different: b.A is properly recorded, but A.C is not. We are left with an odd case of the recording consisting of b.A and C.ReturnInt(), which throws Isolator completely off, resulting in the null reference exception. I will look into improving this exception message in this hard to identify situation. Turning C into a property in the second case would mean that the entire chain is properly recorded and behaves as expected.
Hope this helps,
Doron
Typemock Support