public ConfirmationOutcome Confirm(string text, string caption, ConfirmationOutcome suggestion = ConfirmationOutcome.Yes) { Forms.MessageBoxDefaultButton suggestionButton; switch (suggestion) { // default required to shut the compiler up about "unassigned variable" default: case ConfirmationOutcome.Yes: suggestionButton = Forms.MessageBoxDefaultButton.Button1; break; case ConfirmationOutcome.No: suggestionButton = Forms.MessageBoxDefaultButton.Button2; break; case ConfirmationOutcome.Cancel: suggestionButton = Forms.MessageBoxDefaultButton.Button3; break; } var result = Forms.MessageBox.Show(text, caption, Forms.MessageBoxButtons.YesNoCancel, Forms.MessageBoxIcon.Exclamation, suggestionButton); switch (result) { case Forms.DialogResult.Cancel: return(ConfirmationOutcome.Cancel); case Forms.DialogResult.Yes: return(ConfirmationOutcome.Yes); case Forms.DialogResult.No: return(ConfirmationOutcome.No); default: return(suggestion); } }
public MockedCodeExplorer ConfigureMessageBox(ConfirmationOutcome result) { MessageBox.Setup(m => m.Confirm(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <ConfirmationOutcome>())).Returns(result); return(this); }