Exemple #1
0
        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");
        }