我正在使用Prism的Confirmation类来询问用户是否确认。当我进行单元测试时,确认返回值总是false。也许我可以将InteractionRequest的setter设置为public。我的代码现在看起来像这样,我的单元测试应该验证是否调用了this.copyService.Execute。
public InteractionRequest<Confirmation> CopyProjectConfirmationRequest { get; private set; }
bool confirmationResult = false;
DialogConfirmation dialogConfirmation = new DialogConfirmation
{
Title = "Copy and Convert Project",
Content = string.Format("This Project was created with Version {0} to be used with currentVersion({1}) it must be converted should it copyed and converted Project", projectVersion, toolVersion),
ConfirmButtonText = "Copy & Convert",
DeclineButtonText = "Cancel"
};
this.CopyProjectConfirmationRequest .Raise(dialogConfirmation, cb => { confirmationResult = cb.Confirmed; });
if (confirmationResult)
{
this.copyService.Execute(this.Model);
}
CopyProjectConfirmationRequest
进行桩化 (Stubbing)?即将其放入另一个同样可模拟的类中? - Boklucius