Beispiel #1
0
        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!");
            }
        }
 public MainWindow()
 {
     InitializeComponent();
     _messageBoxManager      = JhMessageBox.GetNewInstance("Invensys", "JhMessageBoxTestApp");
     rbUserMistake.IsChecked = true;
     _viewModel  = MsgBoxViewModel.The;
     DataContext = _viewModel;
     Loaded     += new RoutedEventHandler(MainWindow_Loaded);
 }
Beispiel #3
0
 /// <summary>
 /// Invokes a 'common dialog box' with a default owner-window.
 /// </summary>
 /// <returns>a TaskDialogResult that maps exactly what a Forms.FileDialog would return</returns>
 public JhDialogResult ShowDialog()
 {
     System.Windows.Forms.DialogResult dr;
     //cbl  I don't see that this distinction makes any difference at all.
     if (UseMainWindowAsOwner)
     {
         IWin32Window win32dow = GetMainWindowAsIWin32Window();
         dr = _FileDialog.ShowDialog(win32dow);
     }
     else
     {
         dr = _FileDialog.ShowDialog();
     }
     return(JhMessageBox.ResultFrom(dr));
 }
Beispiel #4
0
        public void TC04_NotifyUserAsync_SimpleCall_CorrectResults()
        {
            using (var testMessageBox = JhMessageBox.BeginTest())
            {
                string summaryText = "basic summary text";
                testMessageBox.TestFacility.SetToWaitForExplicitClose();

                // Show the message-box.
                testMessageBox.NotifyUserAsync(summaryText);

                testMessageBox.TestFacility.AssertAMessageBoxIsBeingShown();
                testMessageBox.TestFacility.AssertOkButtonIsPresent();

                testMessageBox.TestFacility.SimulateClosing(JhDialogResult.Ok);

                testMessageBox.TestFacility.AssertAMessageBoxHasBeenShown();
            }
        }
Beispiel #5
0
        public void TC03_NotifyUserOfMistake_EmulateTimedOut()
        {
            using (var testMessageBox = JhMessageBox.BeginTest())
            {
                // Emulate the action of the user making no selection.

                string summaryText = "basic summary text";
                string detailText  = "detailed text";

                // Show the message-box.
                var r = testMessageBox.NotifyUserOfMistake(summaryText, detailText);

                // Check that it displayed okay..
                Assert.AreEqual(JhDialogResult.TimedOut, r, "The JhMessageBoxWindow failed to return the correct result!");
                testMessageBox.TestFacility.AssertAMessageBoxHasBeenShown();
                testMessageBox.TestFacility.AssertWasWithinSummaryText("summary");
                testMessageBox.TestFacility.AssertWasWithinDetailText("detail");
            }
        }
Beispiel #6
0
        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");
            }
        }
Beispiel #7
0
 /// <summary>
 /// Make a new JhMessageBoxTestFacility object with the default values.
 /// </summary>
 public JhMessageBoxTestFacility(JhMessageBox manager)
 {
     _messageBoxManager = manager;
     _isTesting         = true;
     _isTimeoutsFast    = true;
 }
Beispiel #8
0
        /// <summary>
        /// Create a new JhMessageBoxWindow, with the given options if non-null - otherwise use the DefaultOptions.
        /// </summary>
        /// <param name="options">The options to use for this particular message-box invocation. Leave this null to use the DefaultOptions.</param>
        public JhMessageBoxWindow(JhMessageBox mgr, JhMessageBoxOptions options = null)
        {
            //Console.WriteLine("JhMessageBoxWindow ctor, with options.BackgroundTexture = " + options.BackgroundTexture.ToString());
            _manager = mgr;
            // _options has to be set before InitializeComponent, since that causes properties to be bound, and hence the DataContext creates it's view-model.
            if (options == null)
            {
                _options = mgr.DefaultOptions;
            }
            else
            {
                _options = options;
            }
            _viewModel = JhMessageBoxViewModel.GetInstance(mgr, _options);

            InitializeComponent();

            // Ensure the timeout value isn't ridiculously high (as when the caller mistakenly thinks it's in milliseconds).
            // Use the constant upper-limit value to test it against.
            if (_options.TimeoutPeriodInSeconds > JhMessageBoxOptions.MaximumTimeoutPeriodInSeconds)
            {
                _options.TimeoutPeriodInSeconds = JhMessageBoxOptions.GetDefaultTimeoutValueFor(_options.MessageType);
            }

            if (_options.IsToCenterOverParent)
            {
                this.WindowStartupLocation = System.Windows.WindowStartupLocation.CenterOwner;
            }

            // If the option to use custom styles for the buttons is turned off, then set these button styles to null
            // so that they do not inherit the styles of the parent application.
            if (!_options.IsCustomButtonStyles)
            {
                btnCancel.Style = btnClose.Style = btnNo.Style = btnOk.Style = btnRetry.Style = btnYes.Style = btnIgnore.Style = null;
            }

#if SILVERLIGHT
            _viewModel.CopyCommand = new RelayCommand(
                () => OnCopyCommandExecuted()
                );
            _viewModel.StayCommand = new RelayCommand(
                () => OnStayCommandExecuted(),
                () => StayCommand_CanExecute()
                );
#else
            _viewModel.CopyCommand = new RelayCommand(
                (x) => OnCopyCommandExecuted()
                );
            _viewModel.StayCommand = new RelayCommand(
                (x) => OnStayCommandExecuted(),
                (x) => StayCommand_CanExecute()
                );
#endif

            Loaded += OnLoaded;
#if SILVERLIGHT
            Closing += new EventHandler <System.ComponentModel.CancelEventArgs>(OnClosing);
#else
            ContentRendered += OnContentRendered;
            Closing         += new System.ComponentModel.CancelEventHandler(OnClosing);
#endif
        }
Beispiel #9
0
 public Form1()
 {
     _myInterlocutionFacility = JhMessageBox.GetNewInstance("DesignForge", "DemoApp-WindowsForms");
     InitializeComponent();
 }