< Summary - Syki

Information
Class: Syki.Back.Commands.TestRetryCommandHandler
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Commands/TestRetryCommand.cs
Tag: 56_26538939494
Line coverage
0%
Covered lines: 0
Uncovered lines: 6
Coverable lines: 6
Total lines: 20
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%
Handle()0%620%

File(s)

/home/runner/work/syki/syki/Back/Commands/TestRetryCommand.cs

#LineLine coverage
 1namespace Syki.Back.Commands;
 2
 3[CommandDescription("Comando de teste que falha nas primeiras N execuções e depois tem sucesso.")]
 4public record TestRetryCommand(int FailUntilAttempt) : ICommand;
 5
 06public class TestRetryCommandHandler(SykiDbContext ctx) : ICommandHandler<TestRetryCommand>
 7{
 8    public async Task Handle(int commandId, TestRetryCommand command)
 9    {
 010        var currentCommand = await ctx.Commands.AsNoTracking().FirstAsync(x => x.Id == commandId);
 11
 12        // RetryAttempt is 0-based, FailUntilAttempt is 1-based (attempt 1 = first execution)
 013        var attemptNumber = currentCommand.RetryAttempt + 1;
 14
 015        if (attemptNumber < command.FailUntilAttempt)
 16        {
 017            throw new Exception($"TestRetryCommand failed on attempt {attemptNumber}. Success only on attempt {command.F
 18        }
 019    }
 20}