Exemplo n.º 1
0
        public void InvokeAsyncFeedback_Where_FeedbackAlreadyInProgressAndUserOptsToCancelInprogressFeedBack_Expected_PromptAndFeedbackStarted()
        {
            Mock <IAsyncFeedbackAction> feedbackAction = new Mock <IAsyncFeedbackAction>();

            feedbackAction.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction.Setup(f => f.StartFeedback(It.IsAny <Action <Exception> >())).Verifiable();
            feedbackAction.Setup(f => f.CancelFeedback()).Verifiable();

            Mock <IAsyncFeedbackAction> feedbackAction1 = new Mock <IAsyncFeedbackAction>();

            feedbackAction1.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction1.Setup(f => f.StartFeedback(It.IsAny <Action <Exception> >())).Verifiable();

            Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes);

            CustomContainer.Register <IPopupController>(popup.Object);
            FeedbackInvoker feedbackInvoker = new FeedbackInvoker();

            feedbackInvoker.InvokeFeedback(feedbackAction.Object);
            feedbackInvoker.InvokeFeedback(feedbackAction1.Object);

            popup.Verify(p => p.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>()), Times.Exactly(1));
            feedbackAction.Verify(f => f.StartFeedback(It.IsAny <Action <Exception> >()), Times.Exactly(1));
            feedbackAction.Verify(f => f.CancelFeedback(), Times.Exactly(1));
            feedbackAction1.Verify(f => f.StartFeedback(It.IsAny <Action <Exception> >()), Times.Exactly(1));
            Assert.AreEqual(feedbackAction1.Object, feedbackInvoker.CurrentAction);
        }
Exemplo n.º 2
0
        public void InvokeFeedback_Where_EmailAndRecorderActionsProvidedAndUserAnswersCancelToRecordingPrompt_Expected_NoActionInvoked()
        {
            Mock <IFeedbackAction> feedbackAction1 = new Mock <IFeedbackAction>();

            feedbackAction1.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction1.Setup(f => f.Priority).Returns(2);
            feedbackAction1.Setup(f => f.StartFeedback()).Verifiable();

            Mock <IAsyncFeedbackAction> feedbackAction2 = new Mock <IAsyncFeedbackAction>();

            feedbackAction2.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction2.Setup(f => f.Priority).Returns(1);
            feedbackAction2.Setup(f => f.StartFeedback(It.IsAny <Action <Exception> >())).Verifiable();

            Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Cancel);

            CustomContainer.Register <IPopupController>(popup.Object);
            FeedbackInvoker feedbackInvoker = new FeedbackInvoker();

            feedbackInvoker.InvokeFeedback(feedbackAction1.Object, feedbackAction2.Object);

            popup.Verify(p => p.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>()), Times.Exactly(1));
            feedbackAction2.Verify(f => f.StartFeedback(It.IsAny <Action <Exception> >()), Times.Exactly(0));
            feedbackAction1.Verify(f => f.StartFeedback(), Times.Exactly(0));
            Assert.AreEqual(null, feedbackInvoker.CurrentAction);
        }
Exemplo n.º 3
0
        public void InvokeFeedback_Where_ActionIsNull_Expected_ArgumentNullException()
        {
            Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes);

            CustomContainer.Register <IPopupController>(popup.Object);
            FeedbackInvoker feedbackInvoker = new FeedbackInvoker();

            feedbackInvoker.InvokeFeedback(null);
        }
Exemplo n.º 4
0
        public void InvokeFeedback_Where_RecorderActionIsNull_Expected_ArgumentNullException()
        {
            Mock <IFeedbackAction> feedbackAction1 = new Mock <IFeedbackAction>();

            feedbackAction1.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction1.Setup(f => f.Priority).Returns(2);
            feedbackAction1.Setup(f => f.StartFeedback()).Verifiable();

            Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Cancel);

            CustomContainer.Register <IPopupController>(popup.Object);
            FeedbackInvoker feedbackInvoker = new FeedbackInvoker();

            feedbackInvoker.InvokeFeedback(feedbackAction1.Object, null);
        }
Exemplo n.º 5
0
        public void InvokeFeedback_Where_EmailActionIsNull_Expected_ArgumentNullException()
        {
            Mock <IAsyncFeedbackAction> feedbackAction2 = new Mock <IAsyncFeedbackAction>();

            feedbackAction2.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction2.Setup(f => f.Priority).Returns(1);
            feedbackAction2.Setup(f => f.StartFeedback(It.IsAny <Action <Exception> >())).Verifiable();

            Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Cancel);

            CustomContainer.Register <IPopupController>(popup.Object);
            FeedbackInvoker feedbackInvoker = new FeedbackInvoker();

            feedbackInvoker.InvokeFeedback(null, feedbackAction2.Object);
        }
Exemplo n.º 6
0
        public void InvokeFeedback_Where_UserClicksFeedback_Expected_LimitedPopups()
        {
            Mock <IAsyncFeedbackAction> feedbackAction = new Mock <IAsyncFeedbackAction>();

            feedbackAction.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction.Setup(f => f.Priority).Returns(2);
            feedbackAction.Setup(f => f.StartFeedback()).Verifiable();



            Mock <IPopupController> yesPopup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes);
            Mock <IPopupController> noPopup  = Dev2MockFactory.CreateIPopup(MessageBoxResult.No);

            CustomContainer.Register <IPopupController>(yesPopup.Object);
            FeedbackInvoker theInvoker = new FeedbackInvoker {
                CurrentAction = feedbackAction.Object
            };

            // If it's already recording, display a box to confirm if the user wants to stop the recording, and click Yes
            theInvoker.InvokeFeedback(feedbackAction.Object, feedbackAction.Object);

            // If it's already recording, display a box to confirm if the user wants to stop the recording, and click No
            theInvoker.InvokeFeedback(feedbackAction.Object, feedbackAction.Object);

            // If it's not recording, display the information box, and click Yes
            theInvoker.Popup         = noPopup.Object;
            theInvoker.CurrentAction = null;
            theInvoker.InvokeFeedback(feedbackAction.Object, feedbackAction.Object);
            // If it's not recording, display the information box, and click No
            theInvoker.CurrentAction = null;
            theInvoker.InvokeFeedback(feedbackAction.Object, feedbackAction.Object);

            // Check all popups showed the correct amount of times
            yesPopup.Verify(p => p.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>()), Times.Exactly(2)); // Once for already recording, once for not recording, and clicking yes
            noPopup.Verify(p => p.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>()), Times.Exactly(2));  // Once for already recording, once for not recording, and clicking no
        }
Exemplo n.º 7
0
        public void InvokeAsyncFeedback_Where_ActionCanProvideFeedback_Expected_StartFeedbackInvokedAndCurrentActionSet()
        {
            Mock <IAsyncFeedbackAction> feedbackAction = new Mock <IAsyncFeedbackAction>();

            feedbackAction.Setup(f => f.CanProvideFeedback).Returns(true);
            feedbackAction.Setup(f => f.StartFeedback(It.IsAny <Action <Exception> >())).Verifiable();

            Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes);

            FeedbackInvoker feedbackInvoker = new FeedbackInvoker();

            feedbackInvoker.InvokeFeedback(feedbackAction.Object);

            popup.Verify(p => p.Show(), Times.Exactly(0));
            feedbackAction.Verify(f => f.StartFeedback(It.IsAny <Action <Exception> >()), Times.Exactly(1));
            Assert.AreEqual(feedbackAction.Object, feedbackInvoker.CurrentAction);
        }
Exemplo n.º 8
0
        public void InvokeAsyncFeedback_Where_ActionCantProvideFeedback_NothingInvokedOrSet()
        {
            Mock <IAsyncFeedbackAction> feedbackAction = new Mock <IAsyncFeedbackAction>();

            feedbackAction.Setup(f => f.CanProvideFeedback).Returns(false);
            feedbackAction.Setup(f => f.StartFeedback(It.IsAny <Action <Exception> >())).Verifiable();

            Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes);

            CustomContainer.Register <IPopupController>(popup.Object);
            FeedbackInvoker feedbackInvoker = new FeedbackInvoker();

            feedbackInvoker.InvokeFeedback(feedbackAction.Object);

            popup.Verify(p => p.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>()), Times.Exactly(1));
            feedbackAction.Verify(f => f.StartFeedback(It.IsAny <Action <Exception> >()), Times.Exactly(0));
            Assert.AreEqual(null, feedbackInvoker.CurrentAction);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Sends the report using the imported feedbackinvoker (.
        /// </summary>
        /// <author>jurie.smit</author>
        /// <date>2013/01/15</date>
        public void SendReport()
        {
            var path = new FileInfo(OutputPath);

            if (!Critical)
            {
                FileHelper.CreateTextFile(OutputText, OutputPath);
            }
            else
            {
                //2013.06.27: Ashley Lewis for bug 9817 - critical exceptions hang open during feedback (they close themselves) file may exist
                if (path.Directory != null && !path.Directory.Exists)
                {
                    FileHelper.CreateTextFile(OutputText, OutputPath);
                }
            }
            FeedbackInvoker.InvokeFeedback(FeedbackAction);
            //2013.06.27: Ashley Lewis for bug 9817 - don't close critical exception messages (they close themselves)
            if (!Critical)
            {
                RequestClose();
            }
        }