< Summary

Information
Class: ProjectTemplate.Infrastructure.Data.AuditEntry
Assembly: ProjectTemplate.Infrastructure
File(s): /home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/src/ProjectTemplate.Infrastructure/Data/AuditEntry.cs
Line coverage
100%
Covered lines: 56
Uncovered lines: 0
Coverable lines: 56
Total lines: 92
Line coverage: 100%
Branch coverage
50%
Covered branches: 5
Total branches: 10
Branch coverage: 50%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
.ctor(...)100%11100%
get_Entry()100%11100%
get_TableName()100%11100%
get_State()100%11100%
get_Application()100%11100%
get_ModifiedBy()100%11100%
get_ActorId()100%11100%
get_ActorType()100%11100%
get_MutationBatchId()100%11100%
get_OperationExecutionId()100%11100%
get_ExecutionAttemptId()100%11100%
get_CorrelationId()100%11100%
get_TraceId()100%11100%
get_SpanId()100%11100%
get_DecisionAuditRecordId()100%11100%
get_TenantHash()100%11100%
get_OrganizationHash()100%11100%
get_ModifiedOnUtc()100%11100%
get_KeyValues()100%11100%
get_OriginalValues()100%11100%
get_CurrentValues()100%11100%
get_TemporaryProperties()100%11100%
get_HasTemporaryProperties()100%11100%
ToAuditRecord()37.5%88100%
SerializeAuditValues(...)100%22100%

File(s)

/home/runner/work/NetCoreApplicationTemplate/NetCoreApplicationTemplate/src/ProjectTemplate.Infrastructure/Data/AuditEntry.cs

#LineLine coverage
 1using System.ComponentModel.DataAnnotations;
 2using System.Reflection;
 3using System.Text.Json;
 4using Microsoft.EntityFrameworkCore.ChangeTracking;
 5using ProjectTemplate.Infrastructure.Data.Entities;
 6
 7namespace ProjectTemplate.Infrastructure.Data;
 8
 569internal sealed class AuditEntry(EntityEntry entry)
 10{
 6011    internal EntityEntry Entry { get; } = entry;
 12    [DataType(DataType.Text)]
 16813    internal string TableName { get; set; } = string.Empty;
 14    [DataType(DataType.Text)]
 16815    internal string State { get; set; } = string.Empty;
 16    [DataType(DataType.Text)]
 11217    internal string Application { get; set; } = string.Empty;
 18    [DataType(DataType.Text)]
 16819    internal string ModifiedBy { get; set; } = string.Empty;
 20    [DataType(DataType.Text)]
 16821    internal string ActorId { get; set; } = string.Empty;
 22    [DataType(DataType.Text)]
 16823    internal string ActorType { get; set; } = string.Empty;
 24    [DataType(DataType.Text)]
 16825    internal string MutationBatchId { get; set; } = string.Empty;
 26    [DataType(DataType.Text)]
 11227    internal string? OperationExecutionId { get; set; }
 28    [DataType(DataType.Text)]
 11229    internal string? ExecutionAttemptId { get; set; }
 30    [DataType(DataType.Text)]
 11231    internal string? CorrelationId { get; set; }
 32    [DataType(DataType.Text)]
 11233    internal string? TraceId { get; set; }
 34    [DataType(DataType.Text)]
 11235    internal string? SpanId { get; set; }
 36    [DataType(DataType.Text)]
 11237    internal string? DecisionAuditRecordId { get; set; }
 38    [DataType(DataType.Text)]
 11239    internal string? TenantHash { get; set; }
 40    [DataType(DataType.Text)]
 11241    internal string? OrganizationHash { get; set; }
 42    [DataType(DataType.DateTime)]
 11243    internal DateTime ModifiedOnUtc { get; set; }
 16844    internal Dictionary<string, object> KeyValues { get; } = [];
 14445    internal Dictionary<string, object> OriginalValues { get; } = [];
 67646    internal Dictionary<string, object> CurrentValues { get; } = [];
 17647    internal List<PropertyEntry> TemporaryProperties { get; } = [];
 48
 11249    internal bool HasTemporaryProperties => TemporaryProperties.Count != 0;
 50
 51    internal AuditRecord ToAuditRecord()
 52    {
 5653        string applicationAssembly =
 5654            Assembly.GetEntryAssembly()?.GetName().Name
 5655            ?? GetType().Assembly.GetName().Name
 5656            ?? "Unknown Assembly";
 57
 5658        AuditRecord auditRecord = new()
 5659        {
 5660            SchemaVersion = "1.0",
 5661            Entity = TableName,
 5662            State = State,
 5663            Application = string.IsNullOrWhiteSpace(Application)
 5664                ? applicationAssembly
 5665                : Application,
 5666            ModifiedBy = ModifiedBy,
 5667            ActorId = ActorId,
 5668            ActorType = ActorType,
 5669            MutationBatchId = MutationBatchId,
 5670            OperationExecutionId = OperationExecutionId,
 5671            ExecutionAttemptId = ExecutionAttemptId,
 5672            CorrelationId = CorrelationId,
 5673            TraceId = TraceId,
 5674            SpanId = SpanId,
 5675            DecisionAuditRecordId = DecisionAuditRecordId,
 5676            TenantHash = TenantHash,
 5677            OrganizationHash = OrganizationHash,
 5678            ModifiedOnUtc = ModifiedOnUtc,
 5679            KeyValues = SerializeAuditValues(KeyValues),
 5680            OriginalValues = SerializeAuditValues(OriginalValues),
 5681            CurrentValues = SerializeAuditValues(CurrentValues)
 5682        };
 5683        return auditRecord;
 84    }
 85
 86    private static string SerializeAuditValues(Dictionary<string, object> values)
 87    {
 16888        return values.Count == 0
 16889            ? string.Empty
 16890            : JsonSerializer.Serialize(values);
 91    }
 92}