mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-06-20 22:10:33 -04:00
* Updated number inputs with a more mobile friendly control * Started writing lots of unit tests on PersonHelper to try and hammer out foreign constraint * Fixes side-nav actionable alignment * Added some unit tests * Buffed out the unit tests * Applied input modes throughout the app * Fixed a small bug in refresh token validation to make it work correctly * Try out a new way to block multithreading from interacting with people during series metadata update. * Fixed the lock code to properly lock, which should help with any constraint issues. * Locking notes * Tweaked locking on people to prevent a constraint issue. This slows down the scanner a bit, but not much. Will tweak after validating on a user's server. * Replaced all DBFactory.Series with SeriesBuilder. * Replaced all DBFactory.Volume() with VolumeBuilder * Replaced SeriesMetadata with Builder * Replaced DBFactory.CollectionTag * Lots of refactoring to streamline entity creation * Fixed one of the unit tests * Refactored all of new Library() * Removed tag and genre * Removed new SeriesMetadata * Refactored new Volume() * MangaFile() * ReadingList() * Refactored all of Chapter and ReadingList * Add title to all event widget flows * Updated Base Url to inform user it doesn't work for docker users with non-root user. * Added unit test coverage to FormatChapterTitle and FormatChapterName. * Started on Unit test for scanner, but need to finish it later. --------- Co-authored-by: Robbie Davis <robbie@therobbiedavis.com>
56 lines
2.2 KiB
C#
56 lines
2.2 KiB
C#
using System.Collections.Generic;
|
|
using System.IO.Abstractions.TestingHelpers;
|
|
using System.Linq;
|
|
using API.Entities.Enums;
|
|
using API.Extensions;
|
|
using API.Helpers.Builders;
|
|
using API.Services;
|
|
using API.Services.Tasks.Scanner.Parser;
|
|
using API.Tests.Helpers;
|
|
using Microsoft.Extensions.Logging;
|
|
using NSubstitute;
|
|
using Xunit;
|
|
|
|
namespace API.Tests.Extensions;
|
|
|
|
public class ParserInfoListExtensions
|
|
{
|
|
private readonly IDefaultParser _defaultParser;
|
|
public ParserInfoListExtensions()
|
|
{
|
|
_defaultParser =
|
|
new DefaultParser(new DirectoryService(Substitute.For<ILogger<DirectoryService>>(),
|
|
new MockFileSystem()));
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(new[] {"1", "1", "3-5", "5", "8", "0", "0"}, new[] {"1", "3-5", "5", "8", "0"})]
|
|
public void DistinctVolumesTest(string[] volumeNumbers, string[] expectedNumbers)
|
|
{
|
|
var infos = volumeNumbers.Select(n => new ParserInfo() {Series = "", Volumes = n}).ToList();
|
|
Assert.Equal(expectedNumbers, infos.DistinctVolumes());
|
|
}
|
|
|
|
[Theory]
|
|
[InlineData(new[] {@"Cynthia The Mission - c000-006 (v06) [Desudesu&Brolen].zip"}, new[] {@"E:\Manga\Cynthia the Mission\Cynthia The Mission - c000-006 (v06) [Desudesu&Brolen].zip"}, true)]
|
|
[InlineData(new[] {@"Cynthia The Mission - c000-006 (v06-07) [Desudesu&Brolen].zip"}, new[] {@"E:\Manga\Cynthia the Mission\Cynthia The Mission - c000-006 (v06) [Desudesu&Brolen].zip"}, true)]
|
|
[InlineData(new[] {@"Cynthia The Mission v20 c12-20 [Desudesu&Brolen].zip"}, new[] {@"E:\Manga\Cynthia the Mission\Cynthia The Mission - c000-006 (v06) [Desudesu&Brolen].zip"}, false)]
|
|
public void HasInfoTest(string[] inputInfos, string[] inputChapters, bool expectedHasInfo)
|
|
{
|
|
var infos = new List<ParserInfo>();
|
|
foreach (var filename in inputInfos)
|
|
{
|
|
infos.Add(_defaultParser.Parse(
|
|
filename,
|
|
string.Empty));
|
|
}
|
|
|
|
var files = inputChapters.Select(s => new MangaFileBuilder(s, MangaFormat.Archive, 199).Build()).ToList();
|
|
var chapter = new ChapterBuilder("0-6")
|
|
.WithFiles(files)
|
|
.Build();
|
|
|
|
Assert.Equal(expectedHasInfo, infos.HasInfo(chapter));
|
|
}
|
|
}
|