< Summary

Information
Class: MultiProjectApp.WorkerApp.NotificationWorker
Assembly: MultiProjectApp.WorkerApp
File(s): /home/runner/work/needlr/needlr/src/Examples/MultiProjectApp/MultiProjectApp.WorkerApp/NotificationWorker.cs
Line coverage
0%
Covered lines: 0
Uncovered lines: 7
Coverable lines: 7
Total lines: 24
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 2
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%210%
ExecuteAsync()0%620%

File(s)

/home/runner/work/needlr/needlr/src/Examples/MultiProjectApp/MultiProjectApp.WorkerApp/NotificationWorker.cs

#LineLine coverage
 1using Microsoft.Extensions.Hosting;
 2using MultiProjectApp.Features.Notifications;
 3
 4namespace MultiProjectApp.WorkerApp;
 5
 6/// <summary>A background worker that periodically sends a notification.</summary>
 7public sealed class NotificationWorker : BackgroundService
 8{
 9    private readonly INotificationService _notifications;
 10
 011    public NotificationWorker(INotificationService notifications)
 12    {
 013        _notifications = notifications;
 014    }
 15
 16    protected override async Task ExecuteAsync(CancellationToken stoppingToken)
 17    {
 018        while (!stoppingToken.IsCancellationRequested)
 19        {
 020            _notifications.Send("ops@example.com", $"Worker heartbeat at {DateTime.UtcNow:O}");
 021            await Task.Delay(TimeSpan.FromSeconds(5), stoppingToken);
 22        }
 023    }
 24}