public void ProcessesStore_SendNotifications_ShouldVisitFilterGetNotificationsOnce() { LoadCheckerRunner.Setup(r => r.GetNotifications(It.IsAny <IEnumerable <IProcessModel> >())).Returns(new string[1]); var monitor = new NotificationsProcessor(LoadCheckerRunner.Object, ProcessesStore.Object); monitor.SendNotifications(); LoadCheckerRunner.Verify(r => r.GetNotifications(It.IsAny <IEnumerable <IProcessModel> >()), Times.Once); }
/// <summary> /// This method is called when the <see cref="T:Microsoft.Extensions.Hosting.IHostedService" /> /// starts. The implementation should return a task that represents the lifetime of the long /// running operation(s) being performed. /// </summary> /// /// <param name="stoppingToken"> Triggered when /// <see cref="M:Microsoft.Extensions.Hosting.IHostedService.StopAsync(System.Threading.CancellationToken)" /> /// is called. </param> /// /// <returns> /// A <see cref="T:System.Threading.Tasks.Task" /> that represents the long running operations. /// </returns> /// /// <seealso cref="M:Microsoft.Extensions.Hosting.BackgroundService.ExecuteAsync(CancellationToken)"/> protected override async Task ExecuteAsync(CancellationToken stoppingToken) { Logger.Log(LogLevel.Trace, "ProcessRefresherService:ExecuteAsync Service Starting"); do { ProcessesStore.Refresh(); NotificationsProcessor.SendNotifications(); await Task.Delay(Configuration.ProcessesListRefreshPeriod, stoppingToken); }while (!stoppingToken.IsCancellationRequested); Logger.Log(LogLevel.Trace, "ProcessRefresherService:ExecuteAsync Service Stopping"); }
public void Configuration(IAppBuilder app) { CultureInfo.DefaultThreadCurrentCulture = CultureInfo.GetCultureInfo("en-US"); CultureInfo.DefaultThreadCurrentUICulture = CultureInfo.GetCultureInfo("en-US"); ConfigureAuth(app); SetupInitialSettings(); app.MapSignalR(); WfpictUpdater.Instance.StartUpdatingClients(); #region Hangfire //GlobalConfiguration.Configuration.UseSqlServerStorage("WFPICTContext"); app.UseHangfireDashboard($"/hangfire", new DashboardOptions { Authorization = new[] { new HangfireAuthorizationFilter() //new LocalRequestsOnlyAuthorizationFilter() } }); app.UseHangfireServer(); // CheckForQCRules RecurringJob.AddOrUpdate("FetchAndCheckForQCRules", () => NotificationsProcessor.FetchAndCheckForQcRules(), Cron.HourInterval(3)); // "0 8,12,17 * * *" // Cron.Minutely RecurringJob.AddOrUpdate("SendNotificationEmails", () => NotificationsProcessor.SendNotificationEmails(), "0 9,16 * * *", TimeZoneInfo.FindSystemTimeZoneById("Eastern Standard Time") ); #endregion }