< Summary - Syki

Line coverage
21%
Covered lines: 14
Uncovered lines: 50
Coverable lines: 64
Total lines: 297
Line coverage: 21.8%
Branch coverage
0%
Covered branches: 0
Total branches: 34
Branch coverage: 0%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

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{
 8    public DomainEventId Id { get; set; }
 9    public Guid InstitutionId { get; set; }
 10    public Guid EntityId { get; set; }
 11    public string Type { get; set; }
 12    public string Data { get; set; }
 13    public DomainEventStatus Status { get; set; }
 14    public DateTime OccurredAt { get; set; }
 15    public DateTime? ProcessedAt { get; set; }
 16    public Guid? ProcessorId { get; set; }
 17    public string? Error { get; set; }
 18    public int Duration { get; set; }
 19    public string? ActivityId { get; set; }
 20
 21    public DomainEvent() { }
 22
 23    public DomainEvent(Guid institutionId, Guid entityId, object data, string? activityId)
 24    {
 25        Id = DomainEventId.CreateNew();
 26        EntityId = entityId;
 27        Type = data.GetType().ToString();
 28        Data = data.Serialize();
 29        OccurredAt = DateTime.UtcNow;
 30        InstitutionId = institutionId;
 31        ActivityId = activityId;
 32    }
 33
 34    public void Processed(double duration)
 35    {
 36        ProcessedAt = DateTime.UtcNow;
 37        Duration = Convert.ToInt32(duration);
 38        Status = Error.HasValue() ? DomainEventStatus.Error : DomainEventStatus.Success;
 39    }
 40
 41    public ActivityContext GetParentContext()
 42    {
 43        ActivityContext.TryParse(ActivityId, null, out var parsedContext);
 44        return parsedContext;
 45    }
 46}
 47
 48[StronglyTypedId]
 49public partial struct DomainEventId
 50{
 51    public static DomainEventId CreateNew()
 52    {
 253053        return new DomainEventId(Guid.CreateVersion7());
 54    }
 55
 56    public class DomainEventIdEfCoreValueConverter : Microsoft.EntityFrameworkCore.Storage.ValueConversion.ValueConverte
 57    {
 1258        public DomainEventIdEfCoreValueConverter() : this(null) { }
 59
 60        public DomainEventIdEfCoreValueConverter(Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingH
 661            : base(
 662                id => id.Value,
 663                value => new DomainEventId(value),
 664                mappingHints
 665            )
 666        { }
 67    }
 68}

/home/runner/work/syki/syki/Back/obj/Release/net10.0/StronglyTypedIds/StronglyTypedIds.StronglyTypedIdGenerator/Syki.Back.Events.DomainEventId.g.cs

File '/home/runner/work/syki/syki/Back/obj/Release/net10.0/StronglyTypedIds/StronglyTypedIds.StronglyTypedIdGenerator/Syki.Back.Events.DomainEventId.g.cs' does not exist (any more).

Methods/Properties

CreateNew()
.ctor()
.ctor(Microsoft.EntityFrameworkCore.Storage.ValueConversion.ConverterMappingHints)
get_Value()
.ctor(System.Guid)
New()
.cctor()
Equals(Syki.Back.Events.DomainEventId)
Equals(System.Object)
GetHashCode()
ToString()
op_Equality(Syki.Back.Events.DomainEventId,Syki.Back.Events.DomainEventId)
op_Inequality(Syki.Back.Events.DomainEventId,Syki.Back.Events.DomainEventId)
op_GreaterThan(Syki.Back.Events.DomainEventId,Syki.Back.Events.DomainEventId)
op_LessThan(Syki.Back.Events.DomainEventId,Syki.Back.Events.DomainEventId)
op_GreaterThanOrEqual(Syki.Back.Events.DomainEventId,Syki.Back.Events.DomainEventId)
op_LessThanOrEqual(Syki.Back.Events.DomainEventId,Syki.Back.Events.DomainEventId)
CompareTo(Syki.Back.Events.DomainEventId)
CanConvertFrom(System.ComponentModel.ITypeDescriptorContext,System.Type)
ConvertFrom(System.ComponentModel.ITypeDescriptorContext,System.Globalization.CultureInfo,System.Object)
CanConvertTo(System.ComponentModel.ITypeDescriptorContext,System.Type)
ConvertTo(System.ComponentModel.ITypeDescriptorContext,System.Globalization.CultureInfo,System.Object,System.Type)
Read(System.Text.Json.Utf8JsonReader&,System.Type,System.Text.Json.JsonSerializerOptions)
Write(System.Text.Json.Utf8JsonWriter,Syki.Back.Events.DomainEventId,System.Text.Json.JsonSerializerOptions)
ReadAsPropertyName(System.Text.Json.Utf8JsonReader&,System.Type,System.Text.Json.JsonSerializerOptions)
WriteAsPropertyName(System.Text.Json.Utf8JsonWriter,Syki.Back.Events.DomainEventId,System.Text.Json.JsonSerializerOptions)
Parse(System.String)
Parse(System.String,System.IFormatProvider)
TryParse(System.String,System.IFormatProvider,Syki.Back.Events.DomainEventId&)
ToString(System.String,System.IFormatProvider)
Parse(System.ReadOnlySpan`1<System.Char>)
Parse(System.ReadOnlySpan`1<System.Char>,System.IFormatProvider)
TryParse(System.ReadOnlySpan`1<System.Char>,System.IFormatProvider,Syki.Back.Events.DomainEventId&)
TryFormat(System.Span`1<System.Char>,System.Int32&,System.ReadOnlySpan`1<System.Char>,System.IFormatProvider)
TryFormat(System.Span`1<System.Char>,System.Int32&,System.ReadOnlySpan`1<System.Char>)
TryFormat(System.Span`1<System.Byte>,System.Int32&,System.ReadOnlySpan`1<System.Char>,System.IFormatProvider)