< Summary - Syki

Information
Class: Syki.Back.Commands.TestRetryCommand
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Commands/TestRetryCommand.cs
Tag: 56_26538939494
Line coverage
0%
Covered lines: 0
Uncovered lines: 1
Coverable lines: 1
Total lines: 20
Line coverage: 0%
Branch coverage
N/A
Covered branches: 0
Total branches: 0
Branch coverage: N/A
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_FailUntilAttempt()100%210%

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.")]
 04public record TestRetryCommand(int FailUntilAttempt) : ICommand;
 5
 6public class TestRetryCommandHandler(SykiDbContext ctx) : ICommandHandler<TestRetryCommand>
 7{
 8    public async Task Handle(int commandId, TestRetryCommand command)
 9    {
 10        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)
 13        var attemptNumber = currentCommand.RetryAttempt + 1;
 14
 15        if (attemptNumber < command.FailUntilAttempt)
 16        {
 17            throw new Exception($"TestRetryCommand failed on attempt {attemptNumber}. Success only on attempt {command.F
 18        }
 19    }
 20}

Methods/Properties

get_FailUntilAttempt()