Error:
You are trying to set an expectation on a property that was defined to use PropertyBehavior. Instead of writing code such as this: mockObject.Stub(x => x.SomeProperty).Return(42); You can use the property directly to achieve the same result: mockObject.SomeProperty = 42;
var x = MockRepository.GenerateStub<MyClass>();
x.Stub(s => s.Items).Return(new List<Item>());
public class MyClass
{
public virtual IEnumerable<Item> Items
{
get {return _items;}
private set {_items = value;}
}
}
What am I doing wrong?
I think using a Mock rather than a stub gets around the problem, but there may be a better way I'm missing.
var x = MockRepository.GenerateMock<MyClass>();
x.BackToRecord(BackToRecordOptions.PropertyBehavior);
SetupResult.For(x.Items).Return(new List<Item>());
x.Replay();
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With