< Summary - MechanicsSoftware — Coverage Report

Information
Class: MechanicsSoftware.Application.UseCases.ServiceOrders.Handlers.CreateServiceOrderHandler
Assembly: MechanicsSoftware.Application
File(s): /home/runner/work/mechanics-software/mechanics-software/src/MechanicsSoftware.Application/UseCases/ServiceOrders/Handlers/CreateServiceOrderHandler.cs
Line coverage
100%
Covered lines: 11
Uncovered lines: 0
Coverable lines: 11
Total lines: 26
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
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%44100%

File(s)

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

#LineLine coverage
 1using MechanicsSoftware.Application.Abstractions;
 2using MechanicsSoftware.Application.Exceptions;
 3using MechanicsSoftware.Application.UseCases.ServiceOrders.Commands;
 4using MechanicsSoftware.Domain.Entities;
 5
 6namespace MechanicsSoftware.Application.UseCases.ServiceOrders.Handlers;
 7
 68public sealed class CreateServiceOrderHandler(IAppDbContext db)
 9{
 10    public async Task<ServiceOrderResponse> ExecuteAsync(
 11        CreateServiceOrderCommand command, CancellationToken cancellationToken = default)
 612    {
 613        _ = await db.Customers.FindAsync([command.CustomerId], cancellationToken)
 614            ?? throw new NotFoundException(nameof(Customer), command.CustomerId);
 15
 416        _ = await db.Vehicles.FindAsync([command.VehicleId], cancellationToken)
 417            ?? throw new NotFoundException(nameof(Vehicle), command.VehicleId);
 18
 219        var order = ServiceOrder.Create(Guid.NewGuid(), command.CustomerId, command.VehicleId);
 20
 221        db.ServiceOrders.Add(order);
 222        await db.SaveChangesAsync(cancellationToken);
 23
 224        return ServiceOrderResponse.From(order);
 225    }
 26}