Пример #1
0
        public async Task NormalWithHostedServiceAsync()
        {
            var service = new BackgroundSender(_fixture.Services.GetRequiredService <BackgroundQueue <IWebHookWorkItem> >());
            await service.SendAsync(new WebHookWorkItem(new WebHookNotification(), new WebHook()), CancellationToken.None);

            await Task.Delay(10000);

            Assert.Equal(1, BackgroundSenderFixture.FakeWebHookSenderCount);
        }
Пример #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 ArgNullAsync()
 {
     Assert.Throws <ArgumentNullException>(() => new BackgroundSender(null));
     var service = new BackgroundSender(new BackgroundQueue <IWebHookWorkItem>());
     await Assert.ThrowsAsync <ArgumentNullException>(() => service.SendAsync(null, CancellationToken.None));
 }