您能否帮助实现我在下面的注释框中提到的目标,以完成示例单元测试?
想法是如何检查模拟对象,如果其方法之一被具有特定属性的类型实例调用为预期值/
private IMyObject stub = MockRepository.GenerateMock<IMyObject>();
[TestMethod]
public void MakeMyJob_RecievesValidData_CallsRenderWithCorrectParameter()
{
SomeUtility.MakeMyJob(5,10,stub);
stub.AsswertWasCalled(s=>s.Render(Arg<IViewModel>.Is. //What next?
// In order to check if Render is called
// with a IViewModel instance
// whoose Person.Name property is "Peter"
}
最佳答案
我认为您正在寻找Rhino Mocks中的参数约束。我前段时间尝试了一些框架-link。我想你在找Arg<IViewModel>.Matches (vm => vm.Person.Name == "Peter" )