public void ShowQuestionTest() { MockMessageService messageService = new MockMessageService(); string message = "Hello World"; AssertHelper.ExpectedException<ArgumentNullException>(() => MessageServiceExtensions.ShowQuestion(null, message)); AssertHelper.ExpectedException<ArgumentNullException>(() => MessageServiceExtensions.ShowYesNoQuestion(null, message)); bool showQuestionCalled = false; messageService.ShowQuestionAction = m => { showQuestionCalled = true; Assert.AreEqual(message, m); return true; }; Assert.IsTrue(messageService.ShowQuestion(message) == true); Assert.IsTrue(showQuestionCalled); showQuestionCalled = false; messageService.Clear(); messageService.ShowYesNoQuestionAction = m => { showQuestionCalled = true; Assert.AreEqual(message, m); return true; }; Assert.IsTrue(messageService.ShowYesNoQuestion(message) == true); Assert.IsTrue(showQuestionCalled); }
public void ShowMessageTest() { MockMessageService messageService = new MockMessageService(); string message = "Hello World"; AssertHelper.ExpectedException<ArgumentNullException>(() => MessageServiceExtensions.ShowMessage(null, message)); AssertHelper.ExpectedException<ArgumentNullException>(() => MessageServiceExtensions.ShowWarning(null, message)); AssertHelper.ExpectedException<ArgumentNullException>(() => MessageServiceExtensions.ShowError(null, message)); messageService.ShowMessage(message); Assert.AreEqual(MessageType.Message, messageService.MessageType); Assert.AreEqual(message, messageService.Message); messageService.Clear(); messageService.ShowWarning(message); Assert.AreEqual(MessageType.Warning, messageService.MessageType); Assert.AreEqual(message, messageService.Message); messageService.Clear(); messageService.ShowError(message); Assert.AreEqual(MessageType.Error, messageService.MessageType); Assert.AreEqual(message, messageService.Message); }