一般来说,我是模拟和单元测试的新手。请看下面我在网上找到的代码:
[Test]
public void CanQueryViewUseAccountServiceToFundsTransfer()
{
_viewMock.Expects.One.Method(v => v.GetSourceAccount()).WillReturn("1234");
_viewMock.Expects.One.GetProperty(v => v.TargetAccount).WillReturn("9876");
_viewMock.Expects.One.GetProperty(v => v.TransferAmount).WillReturn(200.00m);
_serviceMock.Expects.Exactly(1).Method(s => s.TransferFunds(null, null, 0m)).With("1234", "9876", 200.00m);
_presenter.Transfer_Clicked();
_mocks.VerifyAllExpectationsHaveBeenMet();
}
我根本找不到任何文档来解释以下几行的作用:
_viewMock.Expects.One.Method //Is this saying it is expecting one and only one function to be called?
_viewMock.Expects.One.GetProperty
我试图自己寻找答案。例如,我在这里查看:http: //nmock3.codeplex.com/documentation,但我能找到的只是常见问题解答。