Skip to content

Kavita is a fast, feature rich, cross platform reading server. Built with the goal of being a full solution for all your reading needs. Setup your own server and share your reading collection with your friends and family.

782 B
Raw Blame
using System.Linq;
using API.Comparators;
using Xunit;

namespace API.Tests.Comparers;

public class ChapterSortComparerZeroFirstTests
{
    [Theory]
    [InlineData(new[] {1, 2, 0}, new[] {0, 1, 2,})]
    [InlineData(new[] {3, 1, 2}, new[] {1, 2, 3})]
    [InlineData(new[] {1, 0, 0}, new[] {0, 0, 1})]
    public void ChapterSortComparerZeroFirstTest(int[] input, int[] expected)
    {
        Assert.Equal(expected, input.OrderBy(f => f, new ChapterSortComparerZeroFirst()).ToArray());
    }

    [Theory]
    [InlineData(new[] {1.0, 0.5, 0.3}, new[] {0.3, 0.5, 1.0})]
    public void ChapterSortComparerZeroFirstTest_Doubles(double[] input, double[] expected)
    {
        Assert.Equal(expected, input.OrderBy(f => f, new ChapterSortComparerZeroFirst()).ToArray());
    }
}