< Summary

Information
Class: Anichron.Worker.Ingestion.Proxy.ProxyBound
Assembly: Anichron.Worker
File(s): /home/runner/work/anichron/anichron/src/Anichron.Worker/Ingestion/Proxy/ProxyBound.cs
Tag: 19_45211875487
Line coverage
100%
Covered lines: 10
Uncovered lines: 0
Coverable lines: 10
Total lines: 25
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
FitTo(...)100%44100%

File(s)

/home/runner/work/anichron/anichron/src/Anichron.Worker/Ingestion/Proxy/ProxyBound.cs

#LineLine coverage
 1using SixLabors.ImageSharp;
 2
 3namespace Anichron.Worker.Ingestion.Proxy;
 4
 5public enum ProxyEdge
 6{
 7    LongEdge = 0,
 8    ShortEdge = 1,
 9}
 10
 11internal readonly record struct ProxyBound(ProxyEdge Edge, int Pixels)
 12{
 13    public Size FitTo(Size source)
 17714    {
 17715        var widthIsLongEdge = source.Width == Math.Max(source.Width, source.Height);
 17716        var boundedIsWidth = Edge == ProxyEdge.LongEdge == widthIsLongEdge;
 17717        var (bounded, other) = boundedIsWidth
 17718            ? (source.Width, source.Height)
 17719            : (source.Height, source.Width);
 17720        var target = Math.Min(bounded, Pixels);
 21
 17722        var scaledOther = Math.Max(1, (int)Math.Round((double)other * target / bounded, MidpointRounding.AwayFromZero));
 17723        return boundedIsWidth ? new Size(target, scaledOther) : new Size(scaledOther, target);
 17724    }
 25}