< Summary - Syki

Information
Class: Syki.Back.Events.DomainEvent
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Events/DomainEvent.cs
Tag: 4_16869239191
Line coverage
96%
Covered lines: 27
Uncovered lines: 1
Coverable lines: 28
Total lines: 68
Line coverage: 96.4%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%11100%
get_InstitutionId()100%11100%
get_EntityId()100%11100%
get_Type()100%11100%
get_Data()100%11100%
get_Status()100%11100%
get_OccurredAt()100%11100%
get_ProcessedAt()100%11100%
get_ProcessorId()100%210%
get_Error()100%11100%
get_Duration()100%11100%
get_ActivityId()100%11100%
.ctor()100%11100%
.ctor(...)100%11100%
Processed(...)50%22100%
GetParentContext()100%11100%

File(s)

/home/runner/work/syki/syki/Back/Events/DomainEvent.cs

#LineLine coverage
 1using StronglyTypedIds;
 2using System.Diagnostics;
 3
 4namespace Syki.Back.Events;
 5
 6public class DomainEvent
 7{
 50448    public DomainEventId Id { get; set; }
 50449    public Guid InstitutionId { get; set; }
 253010    public Guid EntityId { get; set; }
 1511011    public string Type { get; set; }
 504412    public string Data { get; set; }
 251413    public DomainEventStatus Status { get; set; }
 253014    public DateTime OccurredAt { get; set; }
 251415    public DateTime? ProcessedAt { get; set; }
 016    public Guid? ProcessorId { get; set; }
 251417    public string? Error { get; set; }
 251418    public int Duration { get; set; }
 504419    public string? ActivityId { get; set; }
 20
 504821    public DomainEvent() { }
 22
 253023    public DomainEvent(Guid institutionId, Guid entityId, object data, string? activityId)
 24    {
 253025        Id = DomainEventId.CreateNew();
 253026        EntityId = entityId;
 253027        Type = data.GetType().ToString();
 253028        Data = data.Serialize();
 253029        OccurredAt = DateTime.UtcNow;
 253030        InstitutionId = institutionId;
 253031        ActivityId = activityId;
 253032    }
 33
 34    public void Processed(double duration)
 35    {
 251436        ProcessedAt = DateTime.UtcNow;
 251437        Duration = Convert.ToInt32(duration);
 251438        Status = Error.HasValue() ? DomainEventStatus.Error : DomainEventStatus.Success;
 251439    }
 40
 41    public ActivityContext GetParentContext()
 42    {
 251443        ActivityContext.TryParse(ActivityId, null, out var parsedContext);
 251444        return parsedContext;
 45    }
 46}
 47
 48[StronglyTypedId]
 49public partial struct DomainEventId
 50{
 51    public static DomainEventId CreateNew()
 52    {
 53        return new DomainEventId(Guid.CreateVersion7());
 54    }
 55
 56    public class DomainEventIdEfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverte
 57    {
 58        public DomainEventIdEfCoreValueConverter() : this(null) { }
 59
 60        public DomainEventIdEfCoreValueConverter(Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingH
 61            : base(
 62                id => id.Value,
 63                value => new DomainEventId(value),
 64                mappingHints
 65            )
 66        { }
 67    }
 68}