< Summary - Estud

Information
Class: Estud.Back.Domain.Classes.Schedule
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Domain/Classes/Schedule.cs
Tag: 114_29044117136
Line coverage
64%
Covered lines: 24
Uncovered lines: 13
Coverable lines: 37
Total lines: 67
Line coverage: 64.8%
Branch coverage
37%
Covered branches: 12
Total branches: 32
Branch coverage: 37.5%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_Id()100%210%
get_ClassId()100%210%
get_ClassroomId()100%210%
get_TeacherId()100%210%
get_Day()100%11100%
get_Start()100%11100%
get_End()100%11100%
.ctor()100%11100%
.ctor(...)100%11100%
New(...)70%1010100%
GetDiff()100%11100%
Conflict(...)22.72%1832230.76%

File(s)

/home/runner/work/syki/syki/Back/Domain/Classes/Schedule.cs

#LineLine coverage
 1namespace Estud.Back.Domain.Classes;
 2
 3public class Schedule
 4{
 05    public int Id { get; set; }
 06    public int? ClassId { get; set; }
 07    public int? ClassroomId { get; set; }
 08    public int? TeacherId { get; set; }
 12289    public Day Day { get; set; }
 36210    public Hour Start { get; set; }
 35811    public Hour End { get; set; }
 12
 1213    private Schedule() {}
 14
 1215    public Schedule(
 1216        Day day,
 1217        Hour startAt,
 1218        Hour endAt
 1219    ) {
 1220        Day = day;
 1221        Start = startAt;
 1222        End = endAt;
 1223    }
 24
 25    public static OneOf<Schedule, EstudError> New(
 26        Day day,
 27        Hour startAt,
 28        Hour endAt
 29    ) {
 1430        if (!day.IsValid()) return new InvalidDay();
 1431        if (!startAt.IsValid()) return new InvalidHour();
 1432        if (!endAt.IsValid()) return new InvalidHour();
 33
 1434        if (startAt == endAt || endAt < startAt)
 235            return new InvalidSchedule();
 36
 1237        return new Schedule(day, startAt, endAt);
 38    }
 39
 40    public int GetDiff()
 41    {
 16842        return Start.DiffInMinutes(End);
 43    }
 44
 45    public bool Conflict(Schedule other)
 46    {
 247        if (Day != other.Day)
 048            return false;
 49
 250        if (Start == other.Start || End == other.End)
 051            return true;
 52
 253        if (Start < other.Start && other.Start < End)
 254            return true;
 55
 056        if (Start < other.End && other.End < End)
 057            return true;
 58
 059        if (other.Start < Start && Start < other.End)
 060            return true;
 61
 062        if (other.Start < End && End < other.End)
 063            return true;
 64
 065        return false;
 66    }
 67}