< Summary - Syki

Information
Class: Syki.Back.Events.DomainEvent
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Events/DomainEvent.cs
Tag: 21_17346963026
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{
 53288    public DomainEventId Id { get; set; }
 53289    public Guid InstitutionId { get; set; }
 267210    public Guid EntityId { get; set; }
 1596211    public string Type { get; set; }
 532812    public string Data { get; set; }
 265613    public DomainEventStatus Status { get; set; }
 267214    public DateTime OccurredAt { get; set; }
 265615    public DateTime? ProcessedAt { get; set; }
 016    public Guid? ProcessorId { get; set; }
 265617    public string? Error { get; set; }
 265618    public int Duration { get; set; }
 532819    public string? ActivityId { get; set; }
 20
 533221    public DomainEvent() { }
 22
 267223    public DomainEvent(Guid institutionId, Guid entityId, object data, string? activityId)
 24    {
 267225        Id = DomainEventId.CreateNew();
 267226        EntityId = entityId;
 267227        Type = data.GetType().ToString();
 267228        Data = data.Serialize();
 267229        OccurredAt = DateTime.UtcNow;
 267230        InstitutionId = institutionId;
 267231        ActivityId = activityId;
 267232    }
 33
 34    public void Processed(double duration)
 35    {
 265636        ProcessedAt = DateTime.UtcNow;
 265637        Duration = Convert.ToInt32(duration);
 265638        Status = Error.HasValue() ? DomainEventStatus.Error : DomainEventStatus.Success;
 265639    }
 40
 41    public ActivityContext GetParentContext()
 42    {
 265643        ActivityContext.TryParse(ActivityId, null, out var parsedContext);
 265644        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}