// ReSharper disable InconsistentNaming public void StartFeedback_Expected_RecordingStarted() { Mock <IFeedBackRecorder> feedbackRecorder = new Mock <IFeedBackRecorder>(); feedbackRecorder.Setup(r => r.StartRecording(It.IsAny <string>())).Verifiable(); CustomContainer.Register <IFeedBackRecorder>(feedbackRecorder.Object); Mock <IFeedbackInvoker> feedbackInvoker = new Mock <IFeedbackInvoker>(); Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.OK); CustomContainer.Register <IFeedbackInvoker>(feedbackInvoker.Object); CustomContainer.Register <IWindowManager>(new Mock <IWindowManager>().Object); CustomContainer.Register <IPopupController>(popup.Object); RecorderFeedbackAction recorderFeedbackAction = new RecorderFeedbackAction(); recorderFeedbackAction.StartFeedback(); feedbackRecorder.Verify(r => r.StartRecording(It.IsAny <string>()), Times.Exactly(1)); }
public void StartFeedback_Where_FeedbackRecordingAlreadyRunningAndYesIsAnsweredToKillPrompt_Expected_KillAllRecordingTasks() { int callCount = 0; Mock <IFeedBackRecorder> feedbackRecorder = new Mock <IFeedBackRecorder>(); feedbackRecorder.Setup(r => r.StartRecording(It.IsAny <string>())).Callback(() => { callCount++; if (callCount == 1) { throw new FeedbackRecordingInprogressException(); } if (callCount > 2) { throw new Exception("Error in test mock logic, this point should never be reached. This exception's purpose is to end a potential infinite loop."); } } ).Verifiable(); feedbackRecorder.Setup(r => r.KillAllRecordingTasks()).Verifiable(); CustomContainer.Register <IFeedBackRecorder>(feedbackRecorder.Object); Mock <IFeedbackInvoker> feedbackInvoker = new Mock <IFeedbackInvoker>(); Mock <IPopupController> popup = Dev2MockFactory.CreateIPopup(MessageBoxResult.Yes); CustomContainer.Register <IFeedbackInvoker>(feedbackInvoker.Object); CustomContainer.Register <IWindowManager>(new Mock <IWindowManager>().Object); CustomContainer.Register <IPopupController>(popup.Object); RecorderFeedbackAction recorderFeedbackAction = new RecorderFeedbackAction(); recorderFeedbackAction.StartFeedback(); feedbackRecorder.Verify(r => r.StartRecording(It.IsAny <string>()), Times.Exactly(2)); feedbackRecorder.Verify(r => r.KillAllRecordingTasks(), Times.Exactly(1)); popup.Verify(p => p.Show(It.IsAny <string>(), It.IsAny <string>(), It.IsAny <MessageBoxButton>(), It.IsAny <MessageBoxImage>(), It.IsAny <string>()), Times.Exactly(3)); }