< Summary

Information
Class: Bookings.Domain.BookingKey
Assembly: Bookings.Domain
File(s): C:\Code\Bookings\Bookings.Domain\BookingKey.cs
Line coverage
58%
Covered lines: 7
Uncovered lines: 5
Coverable lines: 12
Total lines: 26
Line coverage: 58.3%
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
get_Description()100%210%
get_Type()100%210%
get_Start()100%210%
get_End()100%210%
get_Email()100%210%
From(...)100%11100%

File(s)

C:\Code\Bookings\Bookings.Domain\BookingKey.cs

#LineLine coverage
 1namespace Bookings.Domain
 2{
 3    /*
 4    Learnings: record structs are great for O(1) lookups since they are not allocated on the heap
 5    When you use a ConcurrentDictionary<BookingKey, Guid>:
 6    record struct -> Each key is stored inline in the dictionary’s key slot. No extra heap allocation per key.
 7    record class -> Dictionary stores a reference to a heap-allocated object for each key. Many keys = more GC work.
 8    For O(1) lookups in high-load systems, avoiding unnecessary heap allocations can have a measurable effect.
 9    */
 10
 11    public readonly record struct BookingKey(
 012    string Description,
 013    string Type,
 014    DateOnly Start,
 015    DateOnly End,
 016    string Email)
 17    {
 403518        public static BookingKey From(Booking b) => new(
 403519            Description: b.Description,
 403520            Type: b.Type,
 403521            Start: b.Period.Start,
 403522            End: b.Period.End,
 403523            Email: b.Email
 403524        );
 25    }
 26}