public void FeedbackViewModel_Send_ServerlogFileAttachment_EmailHasServerLogFileAttachment() { var mockSysInfo = new Mock <ISystemInfoService>(); mockSysInfo.Setup(sysInfo => sysInfo.GetSystemInfo()).Returns(GetMockSysInfo()); CustomContainer.Register(mockSysInfo.Object); var mockCommService = new Mock <ICommService <EmailCommMessage> >(); var actual = new EmailCommMessage(); mockCommService.Setup(c => c.SendCommunication(It.IsAny <EmailCommMessage>())).Callback <EmailCommMessage>(msg => { actual = msg; }); var attachmentPath = Path.Combine(_testDir, string.Format("FeedbackTest_{0}.txt", Guid.NewGuid())); File.WriteAllText(attachmentPath, @"test text"); var attachedFiles = new Dictionary <string, string> { { "ServerLog", attachmentPath } }; var feedbackViewModel = new FeedbackViewModel(attachedFiles); //------------Execute Test--------------------------- feedbackViewModel.Send(mockCommService.Object); // Assert email has server log file attachment Assert.AreEqual(attachmentPath, actual.AttachmentLocation, "Wrong file attached"); }
public void FeedbackViewModelSendWithValidCommWithRecordingAttachmentExpectedSendMethodInvokedWithAttachment() { var mockSysInfo = new Mock <ISystemInfoService>(); mockSysInfo.Setup(sysInfo => sysInfo.GetSystemInfo()).Returns(GetMockSysInfo()); CustomContainer.Register(mockSysInfo.Object); var mockCommService = new Mock <ICommService <EmailCommMessage> >(); mockCommService.Setup(c => c.SendCommunication(It.IsAny <EmailCommMessage>())).Verifiable(); // PBI 9598 - 2013.06.10 - TWR : fixed paths var attachmentPath = Path.Combine(_testDir, string.Format("FeedbackTest_{0}.txt", Guid.NewGuid())); File.WriteAllText(attachmentPath, @"test text"); var attachedFiles = new Dictionary <string, string> { { "ServerLog", attachmentPath } }; var viewModel = new FeedbackViewModel(attachedFiles); viewModel.Send(mockCommService.Object); mockCommService.Verify(c => c.SendCommunication(It.IsAny <EmailCommMessage>()) , Times.Once() , "Send Message failed for mail with attachment"); }
[Ignore]//Ashley public void FeedbackViewModel_Send_OutlookIsInstalled_BrowserIsNotOpenedToCommunity() { var mockSysInfo = new Mock <ISystemInfoService>(); mockSysInfo.Setup(c => c.GetSystemInfo()).Returns(GetMockSysInfo()); var mockCommService = new Mock <ICommService <EmailCommMessage> >(); mockCommService.Setup(c => c.SendCommunication(It.IsAny <EmailCommMessage>())).Verifiable(); var attacheFiles = new Dictionary <string, string> { { "RecordingLog", "RecordingLog.log" }, { "ServerLog", "ServerLog.log" }, { "StudioLog", "StudioLog.log" } }; var feedbackViewModel = new FeedbackViewModel(attacheFiles) { DoesFileExists = e => true }; var popupController = new Mock <IBrowserPopupController>(); popupController.Setup(m => m.ShowPopup(It.IsAny <string>())).Verifiable(); feedbackViewModel.BrowserPopupController = popupController.Object; feedbackViewModel.IsOutlookInstalled = () => true; feedbackViewModel.Send(); popupController.Verify(m => m.ShowPopup(It.IsAny <string>()), Times.Never()); }
public void FeedbackViewModel_Send_LogFilesExistToAttach_FilesAreConcatenatedAsAttachments() { var mockSysInfo = new Mock <ISystemInfoService>(); mockSysInfo.Setup(c => c.GetSystemInfo()).Returns(GetMockSysInfo()); CustomContainer.Register(mockSysInfo.Object); var mockCommService = new Mock <ICommService <EmailCommMessage> >(); mockCommService.Setup(c => c.SendCommunication(It.IsAny <EmailCommMessage>())).Verifiable(); var attacheFiles = new Dictionary <string, string> { { "RecordingLog", "RecordingLog.log" }, { "ServerLog", "ServerLog.log" }, { "StudioLog", "StudioLog.log" } }; var feedbackViewModel = new FeedbackViewModel(attacheFiles) { DoesFileExists = e => true }; feedbackViewModel.Send(mockCommService.Object); Assert.AreEqual("RecordingLog.log;ServerLog.log;StudioLog.log", feedbackViewModel.Attachments); }
public void FeedbackViewModelSendWithNullCommServiceExpectedNullException() { var mockSysInfo = new Mock <ISystemInfoService>(); mockSysInfo.Setup(c => c.GetSystemInfo()).Returns(GetMockSysInfo()); var feedbackViewModel = new FeedbackViewModel(); feedbackViewModel.Send(null); }
public void FeedbackViewModelSendWithValidCommServiceExpectedSendMethodInvokedOnCommService() { var mockSysInfo = new Mock <ISystemInfoService>(); mockSysInfo.Setup(c => c.GetSystemInfo()).Returns(GetMockSysInfo()); CustomContainer.Register(mockSysInfo.Object); var mockCommService = new Mock <ICommService <EmailCommMessage> >(); mockCommService.Setup(c => c.SendCommunication(It.IsAny <EmailCommMessage>())).Verifiable(); var feedbackViewModel = new FeedbackViewModel(); feedbackViewModel.Send(mockCommService.Object); mockCommService.Verify(c => c.SendCommunication(It.IsAny <EmailCommMessage>()), Times.Once()); }