Hi,
Well the answer is yes and no. :roll:
in principle the following test works:
[Test]
public void TestChainWithField()
{
using (RecordExpectations rec = new RecordExpectations())
{
ClassForTest.NestedClassForTest.GetString();
rec.Return("Mock");
}
string actual = ClassForTest.NestedClassForTest.GetString();
Assert.AreEqual("Mock", actual);
}
However you must remember that the access to NestedClassForTest is not mocked. What is mocked, is the call to the GetString method only and not the entire chain.
That said, i think this should not prevent you from testing this. You just need to pay close attention to what exactly is mocked and what is not, and verify it answer your testing needs.
:idea: you can use TypeMock Trace tool in order to see exactly which calls are being mocked.