【发布时间】:2014-03-27 13:43:09
【问题描述】:
我正在使用 Prism 的 Confirmation 类向用户询问 Confirmation。当我进行单元测试时,确认的返回值总是错误的。也许我可以公开 InteractionRequest 的设置器。我的代码现在看起来像这样,我的单元测试应该验证 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);
}
【问题讨论】:
标签: c# wpf unit-testing prism confirmation