< Summary - Estud

Information
Class: Estud.Back.Database.Webhooks.WebhookSubscriptionDbConfig
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Database/Webhooks/WebhookSubscriptionDbConfig.cs
Tag: 114_29044117136
Line coverage
100%
Covered lines: 21
Uncovered lines: 0
Coverable lines: 21
Total lines: 35
Line coverage: 100%
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
Configure(...)100%11100%

File(s)

/home/runner/work/syki/syki/Back/Database/Webhooks/WebhookSubscriptionDbConfig.cs

#LineLine coverage
 1using Newtonsoft.Json;
 2using Estud.Back.Domain.Webhooks;
 3
 4namespace Estud.Back.Database.Webhooks;
 5
 6public class WebhookSubscriptionDbConfig : IEntityTypeConfiguration<WebhookSubscription>
 7{
 8    public void Configure(EntityTypeBuilder<WebhookSubscription> entity)
 9    {
 410        entity.ToTable("webhook_subscriptions", DbSchemas.Estud);
 11
 412        entity.HasKey(e => e.Id);
 13
 414        entity.Property(e => e.Events)
 415            .HasConversion(
 416                v => v.Select(x => (int)x).ToList(),
 417                v => v.Select(x => (WebhookEventType)x).ToList()
 418            )
 419            .HasColumnType("integer[]")
 420            .IsRequired();
 21
 422        entity.Property(e => e.CustomHeaders)
 423            .HasConversion(
 424                v => JsonConvert.SerializeObject(v),
 425                v => JsonConvert.DeserializeObject<Dictionary<string, string>>(v) ?? new()
 426            )
 427            .HasColumnType("jsonb")
 428            .IsRequired();
 29
 430        entity.HasMany(e => e.Calls)
 431            .WithOne()
 432            .HasPrincipalKey(e => e.Id)
 433            .HasForeignKey(x => x.WebhookSubscriptionId);
 434    }
 35}