コード例 #1
0
        public void ProcessesStore_Refresh_ShouldVisitRepoGetAllOnce()
        {
            var store = new ProcessesStore(ProcessRepo.Object);

            store.Refresh();

            ProcessRepo.Verify(r => r.GetAll(), Times.Once);
        }
コード例 #2
0
        public void ProcessesStore_GetAll_ShouldReturnCollectionFromRepoAfterRefresh()
        {
            var testProcs = new IProcessModel[] { new ProcessModel() };

            ProcessRepo.Setup(r => r.GetAll()).Returns(testProcs);

            var store = new ProcessesStore(ProcessRepo.Object);

            store.Refresh();
            var procs = store.GetAll();

            Assert.That(procs, Is.EqualTo(testProcs));
        }
コード例 #3
0
        /// <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");
        }