< Summary - MechanicsSoftware — Coverage Report

Information
Class: MechanicsSoftware.Application.UseCases.ServiceOrders.Handlers.EmailExtensions
Assembly: MechanicsSoftware.Application
File(s): /home/runner/work/mechanics-software/mechanics-software/src/MechanicsSoftware.Application/UseCases/ServiceOrders/Handlers/EmailExtensions.cs
Line coverage
100%
Covered lines: 16
Uncovered lines: 0
Coverable lines: 16
Total lines: 34
Line coverage: 100%
Branch coverage
100%
Covered branches: 2
Total branches: 2
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
TrySendStatusEmailAsync()100%22100%

File(s)

/home/runner/work/mechanics-software/mechanics-software/src/MechanicsSoftware.Application/UseCases/ServiceOrders/Handlers/EmailExtensions.cs

#LineLine coverage
 1using MechanicsSoftware.Application.Abstractions;
 2using MechanicsSoftware.Application.Exceptions;
 3using MechanicsSoftware.Domain.Entities;
 4using Microsoft.Extensions.Logging;
 5
 6namespace MechanicsSoftware.Application.UseCases.ServiceOrders.Handlers;
 7
 8internal static class EmailExtensions
 9{
 10    internal static async Task TrySendStatusEmailAsync(
 11        this IEmailNotifier emailNotifier,
 12        IAppDbContext db,
 13        ILogger logger,
 14        ServiceOrder order,
 15        CancellationToken cancellationToken)
 4016    {
 17        try
 4018        {
 4019            var customer = await db.Customers.FindAsync([order.CustomerId], cancellationToken)
 4020                ?? throw new NotFoundException(nameof(Customer), order.CustomerId);
 21
 1622            await emailNotifier.SendStatusChangedAsync(
 1623                toEmail: customer.Email.Value,
 1624                customerName: customer.Name,
 1625                serviceOrderId: order.Id,
 1626                newStatus: order.Status.Value,
 1627                cancellationToken: cancellationToken);
 828        }
 3229        catch (Exception ex)
 3230        {
 3231            logger.FailedToSendStatusEmail(ex, order.Id);
 3232        }
 4033    }
 34}

Methods/Properties

TrySendStatusEmailAsync()