public void ShouldNotBeAbleToHandleNullWindow()
        {
            // GIVEN
            
            var handlerHelper = new DialogHandlerHelper();

            // WHEN
            var canBeHandled = handlerHelper.CanHandleDialog(null);

            // THEN
            Assert.That(canBeHandled, Is.False, "MESSAGE");
        }
        public void ShouldMentionDialogHandlerAsCandidate()
        {
            // GIVEN
            var window = new Window(new IntPtr(123));
            var mainWindowHwnd = new IntPtr(456);

            var dialogHandlerMock = new Mock<IDialogHandler>();
            dialogHandlerMock.Expect(dialog => dialog.CanHandleDialog(window, mainWindowHwnd)).Returns(true);

            var dialogHandlerHelper = new DialogHandlerHelper();
            Assert.That(dialogHandlerHelper.CandidateDialogHandlers.Count, Is.EqualTo(0), "Pr-condition: expected no candidates");

            // WHEN
            dialogHandlerHelper.HandlePossibleCandidate(dialogHandlerMock.Object, window, mainWindowHwnd);

            // THEN
            Assert.That(dialogHandlerHelper.CandidateDialogHandlers.Count, Is.EqualTo(1));
            dialogHandlerMock.VerifyAll();
        }
        public void ShouldMentionPromptDialogAsCandidate()
        {
            // GIVEN
            var mainWindowHwnd = new IntPtr(123);

            var topLevelWindow = new Window(mainWindowHwnd);

            var windowMock = new Mock<Window>(new IntPtr(456));
            windowMock.Expect(window => window.ToplevelWindow).Returns(topLevelWindow);
            windowMock.Expect(window => window.StyleInHex).Returns("94C800C4");

            var helper = new DialogHandlerHelper();

            // WHEN
            helper.CanHandleDialog(windowMock.Object, mainWindowHwnd);

            // THEN
            Assert.That(helper.CandidateDialogHandlers.Count, Is.EqualTo(1), "Unexpected number of candidate dialog handlers");
            Assert.That(helper.CandidateDialogHandlers[0], Is.EqualTo(typeof(PromptDialogHandler).FullName), "Unexpected candidate dialog handler");
        }
        /// <summary>
        /// Executes the java dialog get message.
        /// </summary>
        /// <param name="context">The context.</param>
        private void ExecuteGetJavaDialogMessage(IExecutionContext context)
        {
            DialogHandlerHelper dialogHelper = new DialogHandlerHelper();

            switch (this.DialogType)
            {
                case DialogHandlerType.SimpleJavaAlert:
                    AlertDialogHandler handler = context.GetDialogHandler(this.DialogId) as WatiN.Core.DialogHandlers.AlertDialogHandler;

                    if (handler != null)
                    {
                        handler.WaitUntilExists();
                        handler.OKButton.Click();
                        context.LastFoundValue = handler.Message;
                    }
                    else
                    {
                        throw new ExecutionException(string.Format(CultureInfo.InvariantCulture, Resource.ExecuteGetJavaDialogMessageNoIdAdded, this.DialogId));
                    }
                    break;
                default:
                    throw new ExecutionException(string.Format(CultureInfo.InvariantCulture, Resource.ExecuteAttachDialogHandlerInvalidValue, this.DialogType));
            }
        }