< Summary - Syki

Information
Class: Syki.Back.Commands.CommandBatch
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Commands/CommandBatch.cs
Tag: 4_16869239191
Line coverage
0%
Covered lines: 0
Uncovered lines: 24
Coverable lines: 24
Total lines: 78
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_Id()100%210%
get_InstitutionId()100%210%
get_Type()100%210%
get_Status()100%210%
get_CreatedAt()100%210%
get_ProcessedAt()100%210%
get_EventId()100%210%
get_SourceCommandId()100%210%
get_NextCommandId()100%210%
get_Size()100%210%
.ctor()100%210%
New(...)100%210%
ContinueWith(...)100%210%

File(s)

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

#LineLine coverage
 1using StronglyTypedIds;
 2
 3namespace Syki.Back.Commands;
 4
 5public class CommandBatch
 6{
 07    public CommandBatchId Id { get; set; }
 08    public Guid InstitutionId { get; set; }
 09    public CommandBatchType Type { get; set; }
 010    public CommandBatchStatus Status { get; set; }
 011    public DateTime CreatedAt { get; set; }
 012    public DateTime? ProcessedAt { get; set; }
 13
 14    /// <summary>
 15    /// Id do evento que gerou o lote
 16    /// </summary>
 017    public DomainEventId? EventId { get; set; }
 18
 19    /// <summary>
 20    /// Id do comando que gerou o lote
 21    /// </summary>
 022    public CommandId? SourceCommandId { get; set; }
 23
 24    /// <summary>
 25    /// Id do comando que será executado quando o lote for processado com sucesso
 26    /// </summary>
 027    public CommandId? NextCommandId { get; set; }
 28
 029    public int Size { get; set; }
 30
 031    private CommandBatch() { }
 32
 33    public static CommandBatch New(
 34        Guid institutionId,
 35        CommandBatchType type,
 36        DomainEventId? eventId = null,
 37        CommandId? sourceCommandId = null)
 38    {
 039        return new()
 040        {
 041            Type = type,
 042            Id = CommandBatchId.CreateNew(),
 043            CreatedAt = DateTime.UtcNow,
 044            InstitutionId = institutionId,
 045            Status = CommandBatchStatus.Pending,
 046            EventId = eventId,
 047            SourceCommandId = sourceCommandId,
 048        };
 49    }
 50
 51    public void ContinueWith(Command command)
 52    {
 053        NextCommandId = command.Id;
 054        command.SetAwaiting();
 055    }
 56}
 57
 58[StronglyTypedId]
 59public partial struct CommandBatchId
 60{
 61    public static CommandBatchId CreateNew()
 62    {
 63        return new CommandBatchId(Guid.CreateVersion7());
 64    }
 65
 66    public class CommandBatchIdEfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConvert
 67    {
 68        public CommandBatchIdEfCoreValueConverter() : this(null) { }
 69
 70        public CommandBatchIdEfCoreValueConverter(Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMapping
 71            : base(
 72                id => id.Value,
 73                value => new CommandBatchId(value),
 74                mappingHints
 75            )
 76        { }
 77    }
 78}