using Azaion.Common.DTO; using FluentAssertions; using Xunit; namespace Azaion.Annotator.Test; public class DictTest { public Dictionary> Annotations = new(); [Fact] public void DictAddTest() { Annotations["sd"] = [new YoloLabel(1, 2, 2, 2, 2)]; Annotations["sd"] = [ new YoloLabel(1, 2, 2, 2, 2), new YoloLabel(0, 1, 3, 2, 1) ]; } [Theory] [InlineData(new int[]{}, 0)] [InlineData(new int[]{1, 2, 5}, 1)] [InlineData(new int[]{3, -2, 5}, -2)] [InlineData(new int[]{3, -2, 2, 4}, 2)] [InlineData(new int[]{3, -2, -100, 2, 4}, 2)] public void ComputeClosestToZeroTest(int[] ts, int expected) => ComputeClosestToZero(ts).Should().Be(expected); private int ComputeClosestToZero(int[]? ts) { if (ts is null || ts.Length == 0) return 0; return ts .OrderBy(Math.Abs) .ThenByDescending(x => x) // 2 -2 3 4 -10 .FirstOrDefault(); } }