mirror of
				https://github.com/Kareadita/Kavita.git
				synced 2025-11-03 19:17:05 -05:00 
			
		
		
		
	* Added a lot of tests * More tests! Added a Parser.NormalizePath to normalize all paths within Kavita. * Fixed a bug where MarkChaptersAsUnread implementation wasn't consistent between different files and lead to extra row generation for no reason. * Added more unit tests * Found a better implementation for Natural Sorting. Added tests and validate it works. Next commit will swap out natural Sort for new Extension. * Replaced NaturalSortComparer with OrderByNatural. * Drastically simplified and sped up FindFirstEntry for finding cover images in archives * Initial fix for a epub bug where metadata defines key as absolute path but document uses a relative path. We now have a hack to correct for the epub.
		
			
				
	
	
		
			49 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
			
		
		
	
	
			49 lines
		
	
	
		
			1.0 KiB
		
	
	
	
		
			C#
		
	
	
	
	
	
using System;
 | 
						|
using System.Collections.Generic;
 | 
						|
using API.DTOs.Filtering;
 | 
						|
using API.Entities.Enums;
 | 
						|
using API.Extensions;
 | 
						|
using Xunit;
 | 
						|
 | 
						|
namespace API.Tests.Extensions;
 | 
						|
 | 
						|
public class FilterDtoExtensionsTests
 | 
						|
{
 | 
						|
    [Fact]
 | 
						|
    public void GetSqlFilter_ShouldReturnAllFormats()
 | 
						|
    {
 | 
						|
        var filter = new FilterDto()
 | 
						|
        {
 | 
						|
            Formats = null
 | 
						|
        };
 | 
						|
 | 
						|
        Assert.Equal(Enum.GetValues<MangaFormat>(), filter.GetSqlFilter());
 | 
						|
    }
 | 
						|
 | 
						|
    [Fact]
 | 
						|
    public void GetSqlFilter_ShouldReturnAllFormats2()
 | 
						|
    {
 | 
						|
        var filter = new FilterDto()
 | 
						|
        {
 | 
						|
            Formats = new List<MangaFormat>()
 | 
						|
        };
 | 
						|
 | 
						|
        Assert.Equal(Enum.GetValues<MangaFormat>(), filter.GetSqlFilter());
 | 
						|
    }
 | 
						|
 | 
						|
    [Fact]
 | 
						|
    public void GetSqlFilter_ShouldReturnJust2()
 | 
						|
    {
 | 
						|
        var formats = new List<MangaFormat>()
 | 
						|
        {
 | 
						|
            MangaFormat.Archive, MangaFormat.Epub
 | 
						|
        };
 | 
						|
        var filter = new FilterDto()
 | 
						|
        {
 | 
						|
            Formats = formats
 | 
						|
        };
 | 
						|
 | 
						|
        Assert.Equal(formats, filter.GetSqlFilter());
 | 
						|
    }
 | 
						|
}
 |