public void ReportInactiveSites_ErrorRaisedWhenSendingEmail_ErrorCaughtAndLogged() { ActivityMonitor.Repository.Repository _repository = new ActivityMonitor.Repository.Repository(_log.Object, _mockContext); _reportInactiveSites = new ReportInactiveSites(_repository, _log.Object, _email.Object); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("2345", null, DateTime.Today, null)); _mockContext.tbRPT_OrgSupplier.AddObject(TestHelpers.PopulateTable.AddOrgSupplierDataRow("2345", "INPS")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("2345", "Highland Health Board")); _mockContext.tbRPT_HealthBoardContacts.AddObject(TestHelpers.PopulateTable.AddHealthBoardContactsDataRow(1, "Highland Health Board", "*****@*****.**")); _mockContext.tbRPT_SupplierContacts.AddObject(TestHelpers.PopulateTable.AddSupplierContactsDataRow(1, "INPS", "*****@*****.**")); List<String> _supplierContact = new List<string>(); _supplierContact.Add("*****@*****.**"); List<String> _healthBoardContact = new List<string>(); _healthBoardContact.Add("*****@*****.**"); _email.Setup(email => email.Send(_supplierContact, _healthBoardContact, "2345")).Throws(new Exception("Error sending email")); _reportInactiveSites.SendInactiveReports(); _email.Verify(email => email.Send(_supplierContact, _healthBoardContact, "2345"), Times.Exactly(1)); _log.Verify(log => log.Add("ERROR: Unable to send inactive report email for organisation: " + "2345" + ". Error message: " + "Error sending email")); }
public void ReportInactiveSites_MultipleInactiveOrgs_OneOrgHasNoContacts_EmailSentToOrgWithContacts() { ActivityMonitor.Repository.Repository _repository = new ActivityMonitor.Repository.Repository(_log.Object, _mockContext); _reportInactiveSites = new ReportInactiveSites(_repository, _log.Object, _email.Object); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("1234", null, DateTime.Today, null)); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("2345", null, DateTime.Today, null)); _mockContext.tbRPT_OrgSupplier.AddObject(TestHelpers.PopulateTable.AddOrgSupplierDataRow("2345", "INPS")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("2345", "Highland Health Board")); _mockContext.tbRPT_HealthBoardContacts.AddObject(TestHelpers.PopulateTable.AddHealthBoardContactsDataRow(1, "Highland Health Board", "*****@*****.**")); _mockContext.tbRPT_SupplierContacts.AddObject(TestHelpers.PopulateTable.AddSupplierContactsDataRow(1, "INPS", "*****@*****.**")); List<String> _supplierContact = new List<string>(); _supplierContact.Add("*****@*****.**"); List<String> _healthBoardContact = new List<string>(); _healthBoardContact.Add("*****@*****.**"); _reportInactiveSites.SendInactiveReports(); _log.Verify(log => log.Add("WARNING: No contacts for organisation: " + "1234" + " could be found.")); _email.Verify(email => email.Send(_supplierContact, _healthBoardContact, "2345"), Times.Exactly(1)); _log.Verify(log => log.Add("Inactive email report was sent for site: " + "2345")); Assert.AreEqual(_mockContext.tbRPT_InactiveSites.ElementAt(1).DateEmailSent, DateTime.Today); }
public void TestInitialize() { _mockContext = new ReportingEntitiesMock(); _log = new Mock<ILogger>(); _repository = new ActivityMonitor.Repository.Repository(_log.Object, _mockContext); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("1234", null, DateTime.Today, null)); }
public void TestInitialize() { _mockContext = new ReportingEntitiesMock(); _log = new Mock<ILogger>(); _repository = new ActivityMonitor.Repository.Repository(_log.Object, _mockContext); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("1234", "Highland Health Board")); }
public void TestInitialize() { _mockContext = new ReportingEntitiesMock(); _log = new Mock<ILogger>(); _repository = new ActivityMonitor.Repository.Repository(_log.Object, _mockContext); _mockContext.tbRPT_OrgSupplier.AddObject(TestHelpers.PopulateTable.AddOrgSupplierDataRow("1234", "INPS")); }
public void TestInitialize() { _mockContext = new ReportingEntitiesMock(); _log = new Mock<ILogger>(); _repository = new ActivityMonitor.Repository.Repository(_log.Object, _mockContext); _mockContext.tbRPT_SupplierContacts.AddObject(TestHelpers.PopulateTable.AddSupplierContactsDataRow(1, "INPS", "*****@*****.**")); _mockContext.tbRPT_SupplierContacts.AddObject(TestHelpers.PopulateTable.AddSupplierContactsDataRow(2, "GPASS", "*****@*****.**")); _mockContext.tbRPT_SupplierContacts.AddObject(TestHelpers.PopulateTable.AddSupplierContactsDataRow(1, "INPS", "*****@*****.**")); }
public void TestInitialize() { _mockContext = new ReportingEntitiesMock(); _log = new Mock<ILogger>(); _repository = new ActivityMonitor.Repository.Repository(_log.Object, _mockContext); // Added to setup data for GetHealthBoardContactEmailsAddresses Test _mockContext.tbRPT_HealthBoardContacts.AddObject(TestHelpers.PopulateTable.AddHealthBoardContactsDataRow(1, "Highland Health Board", "*****@*****.**")); _mockContext.tbRPT_HealthBoardContacts.AddObject(TestHelpers.PopulateTable.AddHealthBoardContactsDataRow(2, "Grampian Health Board", "*****@*****.**")); _mockContext.tbRPT_HealthBoardContacts.AddObject(TestHelpers.PopulateTable.AddHealthBoardContactsDataRow(3, "Highland Health Board", "*****@*****.**")); }
public void ReportInactiveSites_InactiveOrgHasNoContacts_NoReportsSent() { // Going to need a proper repository for this test ActivityMonitor.Repository.Repository _repository = new ActivityMonitor.Repository.Repository(_log.Object, _mockContext); _reportInactiveSites = new ReportInactiveSites(_repository, _log.Object, _email.Object); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("1234", null, DateTime.Today, null)); List<String> _emptyList = new List<string>(); _reportInactiveSites.SendInactiveReports(); _email.Verify(email => email.Send(_emptyList, It.IsAny<string>()), Times.Never()); _log.Verify(log => log.Add("WARNING: No contacts for organisation: " + "1234" + " could be found.")); }
static void Main(string[] args) { Logger log = new Logger(); ReportingEntities db = new ReportingEntities(); ActivityMonitor.Repository.Repository repository = new ActivityMonitor.Repository.Repository(log, db); try { string parameter = args[0]; if (parameter == "CheckGPActivityForSelectedSuppliers") { // Check GP Activity For Selected Suppliers - will look for any sites running the selected suppliers software and issue an inactive email // report for any sites found to be inactive in the last 24 hours // Note: If more than 10 inactive sites are found for any healthboards then no reports will be sent to the affected healthboard // This allows us to investigate whether the sites are genuinely inactive or whether or not we've tried to report on non-suitable data // (ie bank holiday, etc) log.Add("Job to run = CheckGPActivityForSelectedSuppliers, healthboard inactive site limit = true"); CheckGPActivityForSelectedSupplier _checkGPActivity = new CheckGPActivityForSelectedSupplier(repository, log, true); _checkGPActivity.RunCheck(); } else if (parameter == "CheckGPActivityForSelectedSuppliersIgnoreHealthboardLimit") { // Check GP Activity For Selected Suppliers - Ignore Healthboard Limit // This will send inactive reports out regardless of how many sites are found to be inactive. log.Add("Job to run = CheckGPActivityForSelectedSuppliers, healthboard inactive site limit = false"); CheckGPActivityForSelectedSupplier _checkGPActivity = new CheckGPActivityForSelectedSupplier(repository, log, false); _checkGPActivity.RunCheck(); } else if (parameter == "CheckSitesMigratingFromGpassToEmis") { // Check all sites migrating from GPASS to EMIS and send out reports if the migration date expires without the switch being detected log.Add("Job to run = CheckSitesMigratingFromGpassToEmis"); CheckMigratingSites _checkMigratingSites = new CheckMigratingSites(repository, log); _checkMigratingSites.UpdateMigratingSitesTable(); _checkMigratingSites.CheckForCompletedMigrations(); _checkMigratingSites.SendNotificationEmailsForLateMigrations(); } else { // this doesn't work. Console.WriteLine("SupplierAutoEmailer.exe written by Eric"); Console.WriteLine("Available parameters:"); Console.WriteLine("CheckGPActivityForSelectedSuppliers"); Console.WriteLine("CheckGPActivityForSelectedSuppliersIgnoreHealthBoardLimit"); Console.WriteLine("CheckSitesMigratingFromGpassToEmis"); Console.WriteLine("Refer to documentation for more information."); Console.ReadLine(); } } catch (Exception ex) { log.Add("EXCEPTION: \n\n" + "Error Message: " + ex.Message + "\n\n" + "Error Stack Trace: " + ex.StackTrace + "\n\n" + "Inner Exception: " + ex.InnerException); return; } finally { log.Write(); Email _email = new Email(repository, log); _email.SendLog(); } }
public void TestInitialize() { _mockContext = new ReportingEntitiesMock(); _log = new Mock<ILogger>(); _repository = new ActivityMonitor.Repository.Repository(_log.Object, _mockContext); _smtpClient = new Mock<ISMTPWrapper>(); _email = new Email(_repository, _log.Object, _smtpClient.Object); _mockContext.tbRPT_OrgSupplier.AddObject(TestHelpers.PopulateTable.AddOrgSupplierDataRow("1234", "INPS")); _mockContext.tbRPT_OrgSupplier.AddObject(TestHelpers.PopulateTable.AddOrgSupplierDataRow("2345", "EMIS")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("1234", "Highland Health Board", "Non-EMIS Site")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("2345", "Highland Health Board", "EMIS Site")); _contacts = new List<string>(); _contacts.Add("*****@*****.**"); _contacts.Add("*****@*****.**"); }
public void TestInitialize() { _mockContext = new ReportingEntitiesMock(); _log = new Mock<ILogger>(); _repository = new ActivityMonitor.Repository.Repository(_log.Object, _mockContext); }
public void ReportInactiveSites_NumberOfInactiveSitesPerHealthBoardLimitExceeded_NoIactiveSites_LogInfo_ReturnsFalse() { // Going to need a proper repository for this test ActivityMonitor.Repository.Repository _repository = new ActivityMonitor.Repository.Repository(_log.Object, _mockContext); _reportInactiveSites = new ReportInactiveSites(_repository, _log.Object, _email.Object); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("1234", DateTime.Today, DateTime.Today, null)); bool _limitExceeded = _reportInactiveSites.NumberOfInactiveSitesPerHealthBoardLimitExceeded(); _log.Verify(log => log.Add("No newly inactive sites")); Assert.IsFalse(_limitExceeded); }
public void ReportInactiveSites_NumberOfInactiveSitesPerHealthBoardLimitExceeded_LimitNotExceeded_ReturnsFalse() { // Going to need a proper repository for this test ActivityMonitor.Repository.Repository _repository = new ActivityMonitor.Repository.Repository(_log.Object, _mockContext); _reportInactiveSites = new ReportInactiveSites(_repository, _log.Object, _email.Object); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("1234", null, DateTime.Today, null)); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("2345", null, DateTime.Today, null)); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("3456", null, DateTime.Today, null)); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("4567", null, DateTime.Today, null)); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("5678", null, DateTime.Today, null)); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("1234", "Highland Health Board")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("2345", "Highland Health Board")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("3456", "Highland Health Board")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("4567", "Grampian Health Board")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("5678", "Grampian Health Board")); bool _limitExceeded = _reportInactiveSites.NumberOfInactiveSitesPerHealthBoardLimitExceeded(); Assert.IsFalse(_limitExceeded); }
public void ReportInactiveSites_NumberOfInactiveSitesPerHealthBoardLimitExceeded_LimitExceeded_ReturnsTrue() { // Going to need a proper repository for this test ActivityMonitor.Repository.Repository _repository = new ActivityMonitor.Repository.Repository(_log.Object, _mockContext); _reportInactiveSites = new ReportInactiveSites(_repository, _log.Object, _email.Object); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("0000", null, DateTime.Today, null)); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("1111", null, DateTime.Today, null)); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("2222", null, DateTime.Today, null)); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("3333", null, DateTime.Today, null)); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("4444", null, DateTime.Today, null)); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("5555", null, DateTime.Today, null)); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("6666", null, DateTime.Today, null)); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("7777", null, DateTime.Today, null)); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("8888", null, DateTime.Today, null)); _mockContext.tbRPT_InactiveSites.AddObject(TestHelpers.PopulateTable.AddInactiveSitesDataRow("9999", null, DateTime.Today, null)); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("0000", "Highland Health Board")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("1111", "Highland Health Board")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("2222", "Highland Health Board")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("3333", "Highland Health Board")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("4444", "Highland Health Board")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("5555", "Highland Health Board")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("6666", "Highland Health Board")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("7777", "Highland Health Board")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("8888", "Highland Health Board")); _mockContext.tbEPS_Organisation.AddObject(TestHelpers.PopulateTable.AddOrganisationDataRow("9999", "Highland Health Board")); bool _limitExceeded = _reportInactiveSites.NumberOfInactiveSitesPerHealthBoardLimitExceeded(); _log.Verify(log => log.Add("WARNING: Healthboard limit exceeded for : Highland Health Board : number of inactive sites: 10")); Assert.IsTrue(_limitExceeded); }
public void TestInitialize() { _mockContext = new ReportingEntitiesMock(); _log = new Mock<ILogger>(); _email = new Mock<IEmail>(); _repository = new ActivityMonitor.Repository.Repository(_log.Object, _mockContext); _checkMigratingSites = new CheckMigratingSites(_repository, _log.Object, _email.Object); }
public void TestInitialize() { _mockContext = new ReportingEntitiesMock(); _log = new Mock<ILogger>(); _repository = new ActivityMonitor.Repository.Repository(_log.Object, _mockContext); _mockContext.tbRPT_DailyActivityGP.AddObject(TestHelpers.PopulateTable.AddGPDailyActivityDataRow("uTest1", 2)); _mockContext.tbRPT_DailyActivityGP.AddObject(TestHelpers.PopulateTable.AddGPDailyActivityDataRow("uTest2", 2)); }