【发布时间】:2013-09-23 18:44:00
【问题描述】:
当我运行以下测试时:
[TestMethod]
public void MyTest()
{
var wizardCatalog = MockRepository.GenerateStub<IWizardCatalog>();
var firstQuestion = MockRepository.GenerateStub<IWizardQuestion>();
wizardCatalog.Stub(i => i.GetFirstQuestion()).Return(firstQuestion);
var choices = new List<IWizardChoice>();
firstQuestion.Stub(i => i.Choices).Return(choices);
}
我得到了这个例外:
您正在尝试对定义为的属性设置期望 使用属性行为。而不是编写这样的代码: mockObject.Stub(x => x.SomeProperty).Return(42);您可以使用 属性直接达到相同的结果:mockObject.SomeProperty = 42;
我读到的所有内容都告诉我这个存根操作是有效的:
var choices = new List<IWizardChoice>();
firstQuestion.Stub(i => i.Choices).Return(choices);
发生了什么事?
【问题讨论】:
标签: testing rhino-mocks