使用FakeItEasy,我试图在假对象上捕获属性值的设置:
首先是界面:
interface ISomeInterface
{
int MyProperty {get;set;}
}
然后是单元测试的片段:
var myObject = A.Fake<ISomeInterface>();
int saved = 0;
A.CallTo (() => myObject.MyProperty).Invokes (x => saved = ?????);
SomeMethod (myObject);
Assert.That (saved, Is.EqualTo (100));
有
void SomeMethod (ISomeInterface intf)
{
intf.MyProperty = 100;
}
我不知道该怎么替换?????
答案 0 :(得分:13)
var myObject = A.Fake<ISomeInterface>();
SomeMethod (myObject);
Assert.That (saved.MyProperty, Is.EqualTo(100));