C# and NaturalMocks; I would appreciate some help with this.
Trying to test this simple property on a derived class
public override string Name
{
protected set
{
if (DmReplicatedThings.Count > 0)
{
DmReplicatedThings[0].Name = value;
}
//else
// Should never happen; just ignore
base.Name = value;
}
}
1)
DmReplicatedThings is a private property method that returns a collection.
When the code tries to retrieve this, the test code attempts to provide a real collection containing real objects.
using (RecordExpectations expect = RecorderManager.StartRecording())
{
BlahBlahBlahCollection things= accessor.DmReplicatedThings;
expect.Return(My_DmReplicatedThings);
things[0].Name = val;
}
expect.Return results in this error
*** Cannot use Return in this sequence, there must be a mocked statement first
Perhaps you are trying to mock a method from mscorlib.
In fact, I see this error quite frequently and I typically do not understand what the problem is.
I've learned one thing that can cause this error (but it not the case here) in which the error text is entirely misleading/inaccurate.
2) Using a mock & RecordExpectations, I have no idea how to verify this line
base.Name = value;