コード例 #1
0
        public async Task DefaultWebHookServiceAsync()
        {
            var queue   = new BackgroundQueue <IWebHookNotification>();
            var service = new DefaultWebHookService(queue);
            var count   = 0;

            await service.NotifyAsync(new WebHookNotification());

            await queue.DequeueAsync(CancellationToken.None).ContinueWith(t => count++);

            Assert.Equal(1, count);
        }
コード例 #2
0
        public async Task NormalAsync()
        {
            var queue   = new BackgroundQueue <IWebHookWorkItem>();
            var service = new BackgroundSender(queue);
            var count   = 0;

            await service.SendAsync(new WebHookWorkItem(new WebHookNotification(), new WebHook()), CancellationToken.None);

            await queue.DequeueAsync(CancellationToken.None).ContinueWith(t => count++);

            Assert.Equal(1, count);
        }
コード例 #3
0
        public async Task DequeueAsync_Task_String()
        {
            // Arrange
            var token = new CancellationToken();

            _taskQueue.Enqueue(t => Task.Run(() => Thread.Sleep(100), t));

            // Act
            var result = await _taskQueue.DequeueAsync(token);

            await result(token);

            // Assert
            Assert.NotNull(result);
        }