mirror of
https://github.com/Kareadita/Kavita.git
synced 2025-06-03 05:34:21 -04:00
* One more unit test for Tachiyomi * Removed some debug code in the manga reader menu * Fixed a typeahead bug where using Enter on add new item or selected options could cause items to disappear from selected state or other visual glitches * Actually fix the selection issue. We needed to filter out selected before we access element * Cleaned up collection detail page to align to new side nav design * Cleaned up some styling on the reading list page * Fixed a bug where side nav would not be visible on the main app due to some weird redirect logic * Fixed a bug where when paging to the last page, a page will be skipped and user will have to refresh manually to view * Fixed some styling bugs on drawer for light themes. Added missing pagination colors on light themes * On mobile screens, add some padding on series-detail page * Fixed a bad test case helper
84 lines
2.5 KiB
C#
84 lines
2.5 KiB
C#
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using API.Entities;
|
|
using API.Entities.Enums;
|
|
using API.Entities.Metadata;
|
|
|
|
namespace API.Tests.Helpers
|
|
{
|
|
/// <summary>
|
|
/// Used to help quickly create DB entities for Unit Testing
|
|
/// </summary>
|
|
public static class EntityFactory
|
|
{
|
|
public static Series CreateSeries(string name)
|
|
{
|
|
return new Series()
|
|
{
|
|
Name = name,
|
|
SortName = name,
|
|
LocalizedName = name,
|
|
NormalizedName = API.Parser.Parser.Normalize(name),
|
|
Volumes = new List<Volume>(),
|
|
Metadata = new SeriesMetadata()
|
|
};
|
|
}
|
|
|
|
public static Volume CreateVolume(string volumeNumber, List<Chapter> chapters = null)
|
|
{
|
|
var chaps = chapters ?? new List<Chapter>();
|
|
var pages = chaps.Count > 0 ? chaps.Max(c => c.Pages) : 0;
|
|
return new Volume()
|
|
{
|
|
Name = volumeNumber,
|
|
Number = (int) API.Parser.Parser.MinimumNumberFromRange(volumeNumber),
|
|
Pages = pages,
|
|
Chapters = chaps
|
|
};
|
|
}
|
|
|
|
public static Chapter CreateChapter(string range, bool isSpecial, List<MangaFile> files = null, int pageCount = 0)
|
|
{
|
|
return new Chapter()
|
|
{
|
|
IsSpecial = isSpecial,
|
|
Range = range,
|
|
Number = API.Parser.Parser.MinimumNumberFromRange(range) + string.Empty,
|
|
Files = files ?? new List<MangaFile>(),
|
|
Pages = pageCount,
|
|
|
|
};
|
|
}
|
|
|
|
public static MangaFile CreateMangaFile(string filename, MangaFormat format, int pages)
|
|
{
|
|
return new MangaFile()
|
|
{
|
|
FilePath = filename,
|
|
Format = format,
|
|
Pages = pages
|
|
};
|
|
}
|
|
|
|
public static SeriesMetadata CreateSeriesMetadata(ICollection<CollectionTag> collectionTags)
|
|
{
|
|
return new SeriesMetadata()
|
|
{
|
|
CollectionTags = collectionTags
|
|
};
|
|
}
|
|
|
|
public static CollectionTag CreateCollectionTag(int id, string title, string summary, bool promoted)
|
|
{
|
|
return new CollectionTag()
|
|
{
|
|
Id = id,
|
|
NormalizedTitle = API.Parser.Parser.Normalize(title).ToUpper(),
|
|
Title = title,
|
|
Summary = summary,
|
|
Promoted = promoted
|
|
};
|
|
}
|
|
}
|
|
}
|