< Summary

Information
Class: Syki.Shared.ListExtensions
Assembly: Shared
File(s): /home/runner/work/syki/syki/Shared/Extensions/ListExtensions.cs
Tag: 22_11348620282
Line coverage
95%
Covered lines: 23
Uncovered lines: 1
Coverable lines: 24
Total lines: 64
Line coverage: 95.8%
Branch coverage
100%
Covered branches: 16
Total branches: 16
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
IsSubsetOf(...)100%66100%
ToAgendas(...)100%88100%
PickRandom(...)100%210%
PickRandom(...)100%11100%
Shuffle(...)100%22100%

File(s)

/home/runner/work/syki/syki/Shared/Extensions/ListExtensions.cs

#LineLine coverage
 1namespace Syki.Shared;
 2
 3public static class ListExtensions
 4{
 5    public static bool IsSubsetOf(this List<Guid> selfs, List<Guid> others)
 6    {
 5047        HashSet<Guid> set = [];
 48578        foreach (var self in selfs)
 9        {
 203110            if (!set.Add(self)) return false;
 11
 222912            if (!others.Contains(self)) return false;
 13        }
 14
 29715        return true;
 20716    }
 17
 18    public static List<AgendaDayOut> ToAgendas(this List<EnrollmentClassOut> classes)
 19    {
 620        var agendas = new List<AgendaDayOut>();
 21
 3822        foreach (var @class in classes)
 23        {
 5824            foreach (var schedule in @class.Schedules)
 25            {
 1626                var discipline = new AgendaDisciplineOut { Name = @class.Discipline, Start = schedule.StartAt, End = sch
 27
 3628                var agenda = agendas.FirstOrDefault(a => a.Day == schedule.Day);
 1629                if (agenda == null)
 30                {
 1231                    agenda = new AgendaDayOut { Day = schedule.Day };
 1232                    agenda.Disciplines.Add(discipline);
 1233                    agendas.Add(agenda);
 1234                    continue;
 35                }
 36
 437                agenda.Disciplines.Add(discipline);
 38            }
 39        }
 40
 1841        agendas = agendas.OrderBy(a => a.Day).ToList();
 3642        foreach (var agenda in agendas)
 43        {
 2844            agenda.Disciplines = agenda.Disciplines.OrderBy(d => d.Start).ToList();
 45        }
 46
 647        return agendas;
 48    }
 49
 50    public static T PickRandom<T>(this IEnumerable<T> source)
 51    {
 052        return source.PickRandom(1).Single();
 53    }
 54
 55    public static IEnumerable<T> PickRandom<T>(this IEnumerable<T> source, int count)
 56    {
 657        return source.Shuffle().Take(count);
 58    }
 59
 60    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source)
 61    {
 13562        return source.OrderBy(x => Guid.NewGuid());
 63    }
 64}