public void TC05_NotifyUser_CustomButton1_CorrectResults() { using (var testMessageBox = JhMessageBox.BeginTest()) { var options = new JhMessageBoxOptions() .SetButtonFlags(JhMessageBoxButtons.Yes | JhMessageBoxButtons.No | JhMessageBoxButtons.Cancel) .SetButtonText(JhDialogResult.Yes, "Absolutely!") .SetSummaryText("The Summary Text") .SetIsAsynchronous(true); // We're going to test the event mechanism as well. options.Completed += new System.EventHandler <MessageBoxCompletedArgs>(OnCompleted); _isCompletedEventRaised = false; // Set this to any value other than what we are going to expect it to be. _theResult = JhDialogResult.Ignore; testMessageBox.TestFacility.SetToWaitForExplicitClose(); // Show the message-box. testMessageBox.NotifyUser(options); testMessageBox.TestFacility.AssertAMessageBoxIsBeingShown(); testMessageBox.TestFacility.AssertNoButtonIsPresent(); testMessageBox.TestFacility.AssertCancelButtonIsPresent(); testMessageBox.TestFacility.AssertButtonIsPresent("Absolutely!"); testMessageBox.TestFacility.SimulateClosing(JhDialogResult.Ok); testMessageBox.TestFacility.AssertAMessageBoxHasBeenShown(); Assert.IsTrue(_isCompletedEventRaised, "Why did the Completed event not get raised?"); Assert.AreEqual(JhDialogResult.Ok, _theResult, "The result did not get set correctly!"); } }
private void btnJhMessageBox_Click(object sender, RoutedEventArgs e) { _viewModel.MessageBoxType = this.JhMessageBoxTypeToUse; JhMessageBoxOptions options = new JhMessageBoxOptions(_viewModel.MessageBoxType); if (_viewModel.IsUsingDefaultTimeoutValue) { options.TimeoutPeriodInSeconds = 0; } else { options.TimeoutPeriodInSeconds = this.TimeToDisplayIt; _viewModel.TimeoutValue = options.TimeoutPeriodInSeconds; } string timeoutValueText = txtTime.Text; //var result = ParseLib.ParseForTimeInterval(timeoutValueText); //if (result.IsOk) //{ // _viewModel.TimeoutValue = (int)result.ValueInSeconds.Value; //} //else //{ // Console.WriteLine("What you put for TimeoutValue doesn't look valid to me. What-up-widat?"); // return; //} //options.TimeoutPeriodInSeconds = _viewModel.TimeoutValue; if (_viewModel.IsIncludingParentWindow) { options.ParentElement = this; } options.BackgroundTexture = _viewModel.BackgroundTexture; options.ButtonFlags = GetButtonsToShow(); options.CaptionAfterPrefix = _viewModel.CaptionAfterPrefix; if (!String.IsNullOrWhiteSpace(_viewModel.CompanyName) || !String.IsNullOrWhiteSpace(_viewModel.ApplicationName)) { options.CaptionPrefix = _viewModel.CompanyName + " " + _viewModel.ApplicationName; } options.DetailText = _viewModel.DetailText; options.SummaryText = _viewModel.SummaryText; options.IsCustomButtonStyles = _viewModel.IsCustomButtonStyles; options.IsSoundEnabled = _viewModel.IsSoundEnabled; options.IsToCenterOverParent = _viewModel.IsToCenterOverParent; options.IsToBeTopmostWindow = _viewModel.IsTopmostWindow; options.IsUsingAeroGlassEffect = _viewModel.IsUsingAeroGlassEffect; options.IsUsingNewerSoundScheme = _viewModel.IsUsingNewerSoundScheme; options.IsUsingNewerIcons = _viewModel.IsUsingNewerIcons; JhDialogResult r = _messageBoxManager.NotifyUser(options); txtResult.Text = "JhDialogResult." + r.ToString(); borderResult.Visibility = System.Windows.Visibility.Visible; lblResult.Visibility = System.Windows.Visibility.Visible; }
public void TC01_NotifyUser_VerifyTextWithinSummaryAndDetail() { using (var testMessageBox = JhMessageBox.BeginTest()) { // Emulate the action of the user selecting "Cancel". testMessageBox.TestFacility.SetButtonToSelect(JhDialogResult.Cancel); // Show the message-box. var options = new JhMessageBoxOptions(JhMessageBoxType.UserMistake); options.SummaryText = "Oh geez"; options.DetailText = "detail text"; options.ButtonFlags = JhMessageBoxButtons.Ok | JhMessageBoxButtons.Cancel; var r = testMessageBox.NotifyUser(options); // Check that it displayed okay.. Assert.AreEqual(JhDialogResult.Cancel, r, "The JhMessageBoxWindow failed to return the correct result!"); testMessageBox.TestFacility.AssertAMessageBoxHasBeenShown(); testMessageBox.TestFacility.AssertWasWithinDetailText("detail"); testMessageBox.TestFacility.AssertWasWithinSummaryText("geez"); } }