如何在 Rhino Mocks 中将项目添加到列表中
我有这样的方法(它是 IMyInteface 的一部分):
interface IMyInterface
{
void MyMethod(IList<Foo> list);
}
我有 ClassUnderTest:
class ClassUnderTest
{
IMyInterface Bar {get; set;}
bool AMethod()
{
var list = new List<Foo>();
Bar.MyMethod(list);
return list.Count()>0;
}
我使用 Rhino Mocks 的测试看起来像这样:
var mocks = new MockRepository();
var myMock = mocks.StrictMock<IMyInterface>();
var myList = new List<Foo>();
var cUT = new ClassUnderTest();
cUT.Bar = myMock;
myMock.MyMethod(myList);
//How can I add some items to myList in the mock?
mocks.Replay(myMock);
var result = cUt.AMethod();
Assert.AreEqual(True, result);
现在如何将一些项目添加到模拟中的 myList 中?
I have method (which is part of IMyInteface) like this:
interface IMyInterface
{
void MyMethod(IList<Foo> list);
}
I have the ClassUnderTest:
class ClassUnderTest
{
IMyInterface Bar {get; set;}
bool AMethod()
{
var list = new List<Foo>();
Bar.MyMethod(list);
return list.Count()>0;
}
My Test with Rhino Mocks looks like this:
var mocks = new MockRepository();
var myMock = mocks.StrictMock<IMyInterface>();
var myList = new List<Foo>();
var cUT = new ClassUnderTest();
cUT.Bar = myMock;
myMock.MyMethod(myList);
//How can I add some items to myList in the mock?
mocks.Replay(myMock);
var result = cUt.AMethod();
Assert.AreEqual(True, result);
How can I now add some items to myList in the mock?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
试试这个:
所以第一个 lambda 函数启用该方法;第二个指定该方法中发生的情况。
我还没有测试过,所以如果有错请告诉我!
Try this:
So the first lambda function enables the method; the second one specifies what happens in the method.
I haven't tested this yet, so let me know if it's wrong!