< Summary - MechanicsSoftware — Coverage Report

Information
Class: MechanicsSoftware.Application.UseCases.Customers.Handlers.UpdateCustomerHandler
Assembly: MechanicsSoftware.Application
File(s): /home/runner/work/mechanics-software/mechanics-software/src/MechanicsSoftware.Application/UseCases/Customers/Handlers/UpdateCustomerHandler.cs
Line coverage
100%
Covered lines: 12
Uncovered lines: 0
Coverable lines: 12
Total lines: 26
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
.ctor(...)100%11100%
ExecuteAsync()100%22100%

File(s)

/home/runner/work/mechanics-software/mechanics-software/src/MechanicsSoftware.Application/UseCases/Customers/Handlers/UpdateCustomerHandler.cs

#LineLine coverage
 1using MechanicsSoftware.Application.Abstractions;
 2using MechanicsSoftware.Application.Exceptions;
 3using MechanicsSoftware.Application.UseCases.Customers.Commands;
 4using MechanicsSoftware.Domain.Entities;
 5using Microsoft.EntityFrameworkCore;
 6
 7namespace MechanicsSoftware.Application.UseCases.Customers.Handlers;
 8
 69public sealed class UpdateCustomerHandler(IAppDbContext db)
 10{
 11    public async Task<CustomerResponse> ExecuteAsync(Guid id, UpdateCustomerCommand command, CancellationToken cancellat
 612    {
 613        var customer = await db.Customers
 614            .FirstOrDefaultAsync(c => c.Id == id, cancellationToken)
 615            ?? throw new NotFoundException(nameof(Customer), id);
 16
 417        customer.Update(
 418            name: command.Name,
 419            email: command.Email,
 420            phone: command.Phone);
 21
 222        await db.SaveChangesAsync(cancellationToken);
 23
 224        return CustomerResponse.From(customer);
 225    }
 26}