< Summary

Information
Class: Syki.Back.Features.Academic.CreateClass.Lesson
Assembly: Back
File(s): /home/runner/work/syki/syki/Back/Features/Academic/CreateClass/Lesson.cs
Tag: 22_11348620282
Line coverage
94%
Covered lines: 34
Uncovered lines: 2
Coverable lines: 36
Total lines: 62
Line coverage: 94.4%
Branch coverage
50%
Covered branches: 1
Total branches: 2
Branch coverage: 50%
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_Date()100%11100%
get_StartAt()100%11100%
get_EndAt()100%11100%
get_Status()100%11100%
get_Attendances()100%11100%
.ctor(...)100%11100%
Finish()100%11100%
GetSchedule()100%11100%
GetFrequency()50%2.5250%
ToOut(...)100%11100%

File(s)

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

#LineLine coverage
 1using Syki.Back.Features.Teacher.CreateLessonAttendance;
 2
 3namespace Syki.Back.Features.Academic.CreateClass;
 4
 5/// <summary>
 6/// Representa uma Aula dentro de uma Turma.
 7/// </summary>
 8public class Lesson
 9{
 1494510    public Guid Id { get; set; }
 983311    public Guid ClassId { get; set; }
 2521812    public DateOnly Date { get; set; }
 2002813    public Hour StartAt { get; set; }
 1491314    public Hour EndAt { get; set; }
 1519815    public LessonStatus Status { get; set; }
 1404516    public List<LessonAttendance> Attendances { get; set; }
 17
 975918    public Lesson(
 975919        Guid classId,
 975920        DateOnly date,
 975921        Hour startAt,
 975922        Hour endAt
 975923    ) {
 975924        Id = Guid.NewGuid();
 975925        ClassId = classId;
 975926        Date = date;
 975927        StartAt = startAt;
 975928        EndAt = endAt;
 975929        Status = LessonStatus.Pending;
 975930    }
 31
 32    public void Finish()
 33    {
 7534        Status = LessonStatus.Finalized;
 7535    }
 36
 37    private string GetSchedule()
 38    {
 511539        return $"{Date.DayOfWeek.ToString().ToEnum<Day>().GetDescription()} {StartAt.GetDescription()}-{EndAt.GetDescrip
 40    }
 41
 42    private decimal GetFrequency()
 43    {
 511544        var total = Attendances.Count;
 1023045        if (total == 0) return 0.00M;
 046        var presences = Attendances.Count(x => x.Present);
 047        return 100M*(1M * presences / (1M * total));
 48    }
 49
 50    public LessonOut ToOut(int number)
 51    {
 511552        return new()
 511553        {
 511554            Id = Id,
 511555            Number = number,
 511556            Date = Date,
 511557            Status = Status,
 511558            Schedule = GetSchedule(),
 511559            Frequency = GetFrequency(),
 511560        };
 61    }
 62}