< Summary

Information
Class: Syki.Back.Features.Academic.CreateClass.Schedule
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Academic/CreateClass/Schedule.cs
Tag: 22_11348620282
Line coverage
95%
Covered lines: 41
Uncovered lines: 2
Coverable lines: 43
Total lines: 81
Line coverage: 95.3%
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%210%
get_Day()100%11100%
get_StartAt()100%11100%
get_EndAt()100%11100%
.ctor()100%11100%
.ctor(...)100%11100%
New(...)100%1010100%
GetDiff()100%11100%
Conflict(...)95.45%22.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{
 2555    public Guid Id { get; set; }
 06    public Guid ClassId { get; set; }
 310627    public Day Day { get; set; }
 95098    public Hour StartAt { get; set; }
 92439    public Hour EndAt { get; set; }
 10
 44611    private Schedule() {}
 12
 25413    public Schedule(
 25414        Day day,
 25415        Hour startAt,
 25416        Hour endAt
 25417    ) {
 25418        Id = Guid.NewGuid();
 25419        Day = day;
 25420        StartAt = startAt;
 25421        EndAt = endAt;
 25422    }
 23
 24    public static OneOf<Schedule, SykiError> New(
 25        Day day,
 26        Hour startAt,
 27        Hour endAt
 28    ) {
 20929        if (!day.IsValid()) return new InvalidDay();
 20830        if (!startAt.IsValid()) return new InvalidHour();
 20731        if (!endAt.IsValid()) return new InvalidHour();
 32
 20533        if (startAt == endAt || endAt < startAt)
 534            return new InvalidSchedule();
 35
 20036        return new Schedule(day, startAt, endAt);
 37    }
 38
 39    public int GetDiff()
 40    {
 432041        return StartAt.DiffInMinutes(EndAt);
 42    }
 43
 44    public bool Conflict(Schedule other)
 45    {
 3046        if (Day != other.Day)
 747            return false;
 48
 2349        if (StartAt == other.StartAt || EndAt == other.EndAt)
 250            return true;
 51
 2152        if (StartAt < other.StartAt && other.StartAt < EndAt)
 753            return true;
 54
 1455        if (StartAt < other.EndAt && other.EndAt < EndAt)
 156            return true;
 57
 1358        if (other.StartAt < StartAt && StartAt < other.EndAt)
 259            return true;
 60
 1161        if (other.StartAt < EndAt && EndAt < other.EndAt)
 062            return true;
 63
 1164        return false;
 65    }
 66
 67    public override string ToString()
 68    {
 1069        return $"{Day.GetDescription()} {StartAt.GetDescription()}-{EndAt.GetDescription()}";
 70    }
 71
 72    public ScheduleOut ToOut()
 73    {
 22374        return new()
 22375        {
 22376            Day = Day,
 22377            StartAt = StartAt,
 22378            EndAt = EndAt,
 22379        };
 80    }
 81}