< Summary - Syki

Information
Class: Syki.Back.Features.Academic.CreateClass.Schedule
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Academic/CreateClass/Schedule.cs
Tag: 21_17346963026
Line coverage
97%
Covered lines: 44
Uncovered lines: 1
Coverable lines: 45
Total lines: 83
Line coverage: 97.7%
Branch coverage
96%
Covered branches: 31
Total branches: 32
Branch coverage: 96.8%
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_ClassId()100%11100%
get_ClassroomId()100%11100%
get_TeacherId()100%11100%
get_Day()100%11100%
get_Start()100%11100%
get_End()100%11100%
.ctor()100%11100%
.ctor(...)100%11100%
New(...)100%1010100%
GetDiff()100%11100%
Conflict(...)95.45%222292.3%
ToString()100%11100%
ToOut()100%11100%

File(s)

/home/runner/work/syki/syki/Back/Features/Academic/CreateClass/Schedule.cs

#LineLine coverage
 1namespace Syki.Back.Features.Academic.CreateClass;
 2
 3public class Schedule
 4{
 7165    public Guid Id { get; set; }
 26    public Guid? ClassId { get; set; }
 27    public Guid? ClassroomId { get; set; }
 28    public Guid? TeacherId { get; set; }
 915209    public Day Day { get; set; }
 2727410    public Hour Start { get; set; }
 2717411    public Hour End { get; set; }
 12
 127213    private Schedule() {}
 14
 71415    public Schedule(
 71416        Day day,
 71417        Hour startAt,
 71418        Hour endAt
 71419    ) {
 71420        Id = Guid.CreateVersion7();
 71421        Day = day;
 71422        Start = startAt;
 71423        End = endAt;
 71424    }
 25
 26    public static OneOf<Schedule, SykiError> New(
 27        Day day,
 28        Hour startAt,
 29        Hour endAt
 30    ) {
 67631        if (!day.IsValid()) return new InvalidDay();
 67432        if (!startAt.IsValid()) return new InvalidHour();
 67233        if (!endAt.IsValid()) return new InvalidHour();
 34
 66835        if (startAt == endAt || endAt < startAt)
 1636            return new InvalidSchedule();
 37
 65238        return new Schedule(day, startAt, endAt);
 39    }
 40
 41    public int GetDiff()
 42    {
 1280843        return Start.DiffInMinutes(End);
 44    }
 45
 46    public bool Conflict(Schedule other)
 47    {
 4648        if (Day != other.Day)
 849            return false;
 50
 3851        if (Start == other.Start || End == other.End)
 452            return true;
 53
 3454        if (Start < other.Start && other.Start < End)
 1655            return true;
 56
 1857        if (Start < other.End && other.End < End)
 258            return true;
 59
 1660        if (other.Start < Start && Start < other.End)
 461            return true;
 62
 1263        if (other.Start < End && End < other.End)
 064            return true;
 65
 1266        return false;
 67    }
 68
 69    public override string ToString()
 70    {
 1871        return $"{Day.GetDescription()} {Start.GetDescription()}-{End.GetDescription()}";
 72    }
 73
 74    public ScheduleOut ToOut()
 75    {
 63876        return new()
 63877        {
 63878            Day = Day,
 63879            StartAt = Start,
 63880            EndAt = End,
 63881        };
 82    }
 83}