我的问题如下:如何测试是否在模拟对象上调用了 ICommand 的 Execute 方法?
我正在使用以下代码:
var mockOperandVM = new Mock<UCOperandViewModel> ();
mockOperandVM.Setup (x => x.EditCommand).Returns (new RelayCommand<String> (x => { }));
var toolbarTrayVM = new UCToolbarTrayViewModel (mockComponentsLocator.Object);
toolbarTrayVM.EditCommand.Execute ("Edit");
mockOperandVM.Verify (x => x.EditCommand.Execute ("Edit"), "EditCommand with 'Edit' parameter was not executed on the mock object.");
我必须在这里指定我在 UCOperandViewModel 上也有一个 EditCommand ICommand,并且我想测试当我在 toolbarTrayVM 上调用 EditCommand.Execute 时该 ICommand 是否被执行。
我在调用验证时收到 ArgumentException。它说“在模拟类型上找不到给定参数的匹配构造函数。”。
提前致谢。