< Summary - Syki

Information
Class: Syki.Shared.ListExtensions
Assembly: Shared
File(s): /home/runner/work/syki/syki/Shared/Extensions/ListExtensions.cs
Tag: 4_16869239191
Line coverage
92%
Covered lines: 24
Uncovered lines: 2
Coverable lines: 26
Total lines: 71
Line coverage: 92.3%
Branch coverage
88%
Covered branches: 16
Total branches: 18
Branch coverage: 88.8%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
IsSubsetOf(...)100%66100%
IsEquivalentTo(...)0%620%
ToAgendas(...)100%88100%
PickRandom(...)100%11100%
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    {
 11547        HashSet<Guid> set = [];
 114928        foreach (var self in selfs)
 9        {
 480610            if (!set.Add(self)) return false;
 11
 520412            if (!others.Contains(self)) return false;
 13        }
 14
 73815        return true;
 41616    }
 17
 18    public static bool IsEquivalentTo(this List<Guid> selfs, List<Guid> others)
 19    {
 020        if (selfs.Count != others.Count) return false;
 21
 022        return selfs.IsSubsetOf(others);
 23    }
 24
 25    public static List<AgendaDayOut> ToAgendas(this List<EnrollmentClassOut> classes)
 26    {
 1227        var agendas = new List<AgendaDayOut>();
 28
 7629        foreach (var @class in classes)
 30        {
 11631            foreach (var schedule in @class.Schedules)
 32            {
 3233                var discipline = new AgendaDisciplineOut { Name = @class.Discipline, Start = schedule.StartAt, End = sch
 34
 7235                var agenda = agendas.FirstOrDefault(a => a.Day == schedule.Day);
 3236                if (agenda == null)
 37                {
 2438                    agenda = new AgendaDayOut { Day = schedule.Day };
 2439                    agenda.Disciplines.Add(discipline);
 2440                    agendas.Add(agenda);
 2441                    continue;
 42                }
 43
 844                agenda.Disciplines.Add(discipline);
 45            }
 46        }
 47
 2848        agendas = agendas.OrderBy(a => a.Day).ToList();
 7249        foreach (var agenda in agendas)
 50        {
 3851            agenda.Disciplines = agenda.Disciplines.OrderBy(d => d.Start).ToList();
 52        }
 53
 1254        return agendas;
 55    }
 56
 57    public static T PickRandom<T>(this IEnumerable<T> source)
 58    {
 59459        return source.PickRandom(1).Single();
 60    }
 61
 62    public static IEnumerable<T> PickRandom<T>(this IEnumerable<T> source, int count)
 63    {
 60664        return source.Shuffle().Take(count);
 65    }
 66
 67    public static IEnumerable<T> Shuffle<T>(this IEnumerable<T> source)
 68    {
 254582869        return source.OrderBy(x => Guid.CreateVersion7());
 70    }
 71}