Rhino 模拟最后一次调用返回 IList?
当使用 Rhino 模拟时,是否可以使其返回一个新列表
MockRepository mock = new MockRepository();
IPersonRepository person = mock.Stub<IPersonRepository>();
using(mock.Record())
{
person.GetPersonByFKId(1);
IList<Person> people= new List<Person>();
people.Add(new Person(100, "Ted", 200));
LastCall.Return(people);
}
Address add = new Address (person);
person.GetPeopleWithAddressField("Ted");//FAIL it will try to ref people
//list and it is always null
上面的语法是否有效?我已经用 Stub 和 Dynamic Mock 尝试过,并且 people 始终为空。不确定我做错了什么。
When using Rhino mocks is it possible to make it return a new List
MockRepository mock = new MockRepository();
IPersonRepository person = mock.Stub<IPersonRepository>();
using(mock.Record())
{
person.GetPersonByFKId(1);
IList<Person> people= new List<Person>();
people.Add(new Person(100, "Ted", 200));
LastCall.Return(people);
}
Address add = new Address (person);
person.GetPeopleWithAddressField("Ted");//FAIL it will try to ref people
//list and it is always null
Is the Syntax above valid? I have tried it with both Stub and Dynamic Mock and people is always null. Not sure what I am doing wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
是的,您可以返回一个新列表。不过,使用 AAA 语法会更容易:
Yes, you can return a new List. It would be easier to use the AAA syntax though: