< Summary - Syki

Information
Class: Syki.Back.Commands.Domain.Classes.Schedule
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Domain/Classes/Schedule.cs
Tag: 97_27801654829
Line coverage
0%
Covered lines: 0
Uncovered lines: 37
Coverable lines: 37
Total lines: 67
Line coverage: 0%
Branch coverage
0%
Covered branches: 0
Total branches: 32
Branch coverage: 0%
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%210%
get_Start()100%210%
get_End()100%210%
.ctor()100%210%
.ctor(...)100%210%
New(...)0%110100%
GetDiff()100%210%
Conflict(...)0%506220%

File(s)

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

#LineLine coverage
 1namespace Syki.Back.Commands.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; }
 09    public Day Day { get; set; }
 010    public Hour Start { get; set; }
 011    public Hour End { get; set; }
 12
 013    private Schedule() {}
 14
 015    public Schedule(
 016        Day day,
 017        Hour startAt,
 018        Hour endAt
 019    ) {
 020        Day = day;
 021        Start = startAt;
 022        End = endAt;
 023    }
 24
 25    public static OneOf<Schedule, SykiError> New(
 26        Day day,
 27        Hour startAt,
 28        Hour endAt
 29    ) {
 030        if (!day.IsValid()) return new InvalidDay();
 031        if (!startAt.IsValid()) return new InvalidHour();
 032        if (!endAt.IsValid()) return new InvalidHour();
 33
 034        if (startAt == endAt || endAt < startAt)
 035            return new InvalidSchedule();
 36
 037        return new Schedule(day, startAt, endAt);
 38    }
 39
 40    public int GetDiff()
 41    {
 042        return Start.DiffInMinutes(End);
 43    }
 44
 45    public bool Conflict(Schedule other)
 46    {
 047        if (Day != other.Day)
 048            return false;
 49
 050        if (Start == other.Start || End == other.End)
 051            return true;
 52
 053        if (Start < other.Start && other.Start < End)
 054            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}