.NET 7 + Spring Cleaning (#1677)
* Updated to net7.0 * Updated GA to .net 7 * Updated System.IO.Abstractions to use New factory. * Converted Regex into SourceGenerator in Parser. * Updated more regex to source generators. * Enabled Nullability and more regex changes throughout codebase. * Parser is 100% GeneratedRegexified * Lots of nullability code * Enabled nullability for all repositories. * Fixed another unit test * Refactored some code around and took care of some todos. * Updating code for nullability and cleaning up methods that aren't used anymore. Refctored all uses of Parser.Normalize() to use new extension * More nullability exercises. 500 warnings to go. * Fixed a bug where custom file uploads for entities wouldn't save in webP. * Nullability is done for all DTOs * Fixed all unit tests and nullability for the project. Only OPDS is left which will be done with an upcoming OPDS enhancement. * Use localization in book service after validating * Code smells * Switched to preview build of swashbuckle for .net7 support * Fixed up merge issues * Disable emulate comic book when on single page reader * Fixed a regression where double page renderer wouldn't layout the images correctly * Updated to swashbuckle which support .net 7 * Fixed a bad GA action * Some code cleanup * More code smells * Took care of most of nullable issues * Fixed a broken test due to having more than one test run in parallel * I'm really not sure why the unit tests are failing or are so extremely slow on .net 7 * Updated all dependencies * Fixed up build and removed hardcoded framework from build scripts. (this merge removes Regex Source generators). Unit tests are completely busted. * Unit tests and code cleanup. Needs shakeout now. * Adjusted Series model since a few fields are not-nullable. Removed dead imports on the project. * Refactored to use Builder pattern for all unit tests. * Switched nullability down to warnings. It wasn't possible to switch due to constraint issues in DB Migration.
This commit is contained in:
parent
76fe3fd64a
commit
5d1dd7b3f0
283 changed files with 4221 additions and 4593 deletions
|
|
@ -5,7 +5,6 @@ using System.IO.Abstractions.TestingHelpers;
|
|||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using API.Archive;
|
||||
using API.Data.Metadata;
|
||||
using API.Services;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NetVips;
|
||||
|
|
|
|||
|
|
@ -1,18 +1,15 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
using System.IO.Compression;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.Data;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Extensions;
|
||||
using API.Services;
|
||||
using API.Services.Tasks;
|
||||
using API.SignalR;
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
|
|
@ -10,9 +9,12 @@ using API.Data.Repositories;
|
|||
using API.DTOs.Reader;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Entities.Metadata;
|
||||
using API.Extensions;
|
||||
using API.Helpers;
|
||||
using API.Services;
|
||||
using API.SignalR;
|
||||
using API.Tests.Helpers.Builders;
|
||||
using AutoMapper;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
|
@ -136,27 +138,22 @@ public class BookmarkServiceTests
|
|||
// Delete all Series to reset state
|
||||
await ResetDB();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithFormat(MangaFormat.Epub)
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("1")
|
||||
.Build())
|
||||
.Build())
|
||||
.Build();
|
||||
series.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library() {
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
},
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
};
|
||||
|
||||
_context.Series.Add(series);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
_context.AppUser.Add(new AppUser()
|
||||
{
|
||||
|
|
@ -194,27 +191,22 @@ public class BookmarkServiceTests
|
|||
// Delete all Series to reset state
|
||||
await ResetDB();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithFormat(MangaFormat.Epub)
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithNumber(1)
|
||||
.WithChapter(new ChapterBuilder("0")
|
||||
.Build())
|
||||
.Build())
|
||||
.Build();
|
||||
series.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library() {
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
},
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
_context.Series.Add(series);
|
||||
|
||||
|
||||
_context.AppUser.Add(new AppUser()
|
||||
|
|
@ -270,28 +262,22 @@ public class BookmarkServiceTests
|
|||
// Delete all Series to reset state
|
||||
await ResetDB();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithFormat(MangaFormat.Epub)
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithNumber(1)
|
||||
.WithChapter(new ChapterBuilder("1")
|
||||
.Build())
|
||||
.Build())
|
||||
.Build();
|
||||
series.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library() {
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
},
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
};
|
||||
|
||||
_context.Series.Add(series);
|
||||
|
||||
_context.AppUser.Add(new AppUser()
|
||||
{
|
||||
|
|
@ -342,7 +328,7 @@ public class BookmarkServiceTests
|
|||
|
||||
|
||||
Assert.Equal(2, ds.GetFiles(BookmarkDirectory, searchOption:SearchOption.AllDirectories).Count());
|
||||
Assert.False(ds.FileSystem.FileInfo.FromFileName(Path.Join(BookmarkDirectory, "1/1/1/0001.jpg")).Exists);
|
||||
Assert.False(ds.FileSystem.FileInfo.New(Path.Join(BookmarkDirectory, "1/1/1/0001.jpg")).Exists);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
@ -357,27 +343,23 @@ public class BookmarkServiceTests
|
|||
// Delete all Series to reset state
|
||||
await ResetDB();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithFormat(MangaFormat.Epub)
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithNumber(1)
|
||||
.WithChapter(new ChapterBuilder("1")
|
||||
.Build())
|
||||
.Build())
|
||||
.Build();
|
||||
series.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library() {
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
},
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
};
|
||||
|
||||
_context.Series.Add(series);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
_context.AppUser.Add(new AppUser()
|
||||
{
|
||||
|
|
@ -419,28 +401,22 @@ public class BookmarkServiceTests
|
|||
// Delete all Series to reset state
|
||||
await ResetDB();
|
||||
|
||||
_context.Series.Add(new Series()
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithFormat(MangaFormat.Epub)
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithNumber(1)
|
||||
.WithChapter(new ChapterBuilder("1")
|
||||
.Build())
|
||||
.Build())
|
||||
.Build();
|
||||
series.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library() {
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
},
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
};
|
||||
|
||||
_context.Series.Add(series);
|
||||
|
||||
_context.AppUser.Add(new AppUser()
|
||||
{
|
||||
|
|
@ -483,27 +459,19 @@ public class BookmarkServiceTests
|
|||
|
||||
// Delete all Series to reset state
|
||||
await ResetDB();
|
||||
var series = new Series()
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithFormat(MangaFormat.Epub)
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithNumber(1)
|
||||
.WithChapter(new ChapterBuilder("1")
|
||||
.Build())
|
||||
.Build())
|
||||
.Build();
|
||||
series.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
},
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
};
|
||||
|
||||
_context.Series.Add(series);
|
||||
|
|
@ -528,7 +496,7 @@ public class BookmarkServiceTests
|
|||
await _context.SaveChangesAsync();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByIdAsync(1, AppUserIncludes.Bookmarks);
|
||||
Assert.NotEmpty(user.Bookmarks);
|
||||
Assert.NotEmpty(user!.Bookmarks);
|
||||
|
||||
series.Volumes = new List<Volume>();
|
||||
_unitOfWork.SeriesRepository.Update(series);
|
||||
|
|
|
|||
|
|
@ -171,6 +171,7 @@ public class CacheServiceTests
|
|||
var c = new Chapter()
|
||||
{
|
||||
Number = "1",
|
||||
Range = "1",
|
||||
Files = new List<MangaFile>()
|
||||
{
|
||||
new MangaFile()
|
||||
|
|
@ -272,6 +273,8 @@ public class CacheServiceTests
|
|||
|
||||
var c = new Chapter()
|
||||
{
|
||||
Number = "1",
|
||||
Range = "1",
|
||||
Files = new List<MangaFile>()
|
||||
{
|
||||
new MangaFile()
|
||||
|
|
@ -303,6 +306,8 @@ public class CacheServiceTests
|
|||
var c = new Chapter()
|
||||
{
|
||||
Id = 1,
|
||||
Number = "1",
|
||||
Range = "1",
|
||||
Files = new List<MangaFile>()
|
||||
};
|
||||
|
||||
|
|
@ -340,6 +345,8 @@ public class CacheServiceTests
|
|||
var c = new Chapter()
|
||||
{
|
||||
Id = 1,
|
||||
Number = "1",
|
||||
Range = "1",
|
||||
Files = new List<MangaFile>()
|
||||
{
|
||||
new MangaFile()
|
||||
|
|
@ -392,6 +399,8 @@ public class CacheServiceTests
|
|||
var c = new Chapter()
|
||||
{
|
||||
Id = 1,
|
||||
Number = "1",
|
||||
Range = "1",
|
||||
Files = new List<MangaFile>()
|
||||
{
|
||||
new MangaFile()
|
||||
|
|
@ -440,6 +449,8 @@ public class CacheServiceTests
|
|||
var c = new Chapter()
|
||||
{
|
||||
Id = 1,
|
||||
Number = "1",
|
||||
Range = "1",
|
||||
Files = new List<MangaFile>()
|
||||
{
|
||||
new MangaFile()
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
using System.Linq;
|
||||
|
|
@ -8,21 +7,16 @@ using System.Threading.Tasks;
|
|||
using API.Data;
|
||||
using API.Data.Repositories;
|
||||
using API.DTOs.Filtering;
|
||||
using API.DTOs.Settings;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Entities.Metadata;
|
||||
using API.Extensions;
|
||||
using API.Helpers;
|
||||
using API.Helpers.Converters;
|
||||
using API.Services;
|
||||
using API.Services.Tasks;
|
||||
using API.SignalR;
|
||||
using API.Tests.Helpers;
|
||||
using AutoMapper;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using API.Tests.Helpers.Builders;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
|
@ -149,6 +143,8 @@ public class CleanupServiceTests : AbstractDbTest
|
|||
var v = DbFactory.Volume("1");
|
||||
v.Chapters.Add(new Chapter()
|
||||
{
|
||||
Number = "0",
|
||||
Range = "0",
|
||||
CoverImage = "v01_c01.jpg"
|
||||
});
|
||||
v.CoverImage = "v01_c01.jpg";
|
||||
|
|
@ -161,6 +157,8 @@ public class CleanupServiceTests : AbstractDbTest
|
|||
v = DbFactory.Volume("1");
|
||||
v.Chapters.Add(new Chapter()
|
||||
{
|
||||
Number = "0",
|
||||
Range = "0",
|
||||
CoverImage = "v01_c03.jpg"
|
||||
});
|
||||
v.CoverImage = "v01_c03jpg";
|
||||
|
|
@ -200,6 +198,7 @@ public class CleanupServiceTests : AbstractDbTest
|
|||
s.Metadata.CollectionTags.Add(new CollectionTag()
|
||||
{
|
||||
Title = "Something",
|
||||
NormalizedTitle = "Something".ToNormalized(),
|
||||
CoverImage = $"{ImageService.GetCollectionTagFormat(1)}.jpg"
|
||||
});
|
||||
s.CoverImage = $"{ImageService.GetSeriesFormat(1)}.jpg";
|
||||
|
|
@ -211,6 +210,7 @@ public class CleanupServiceTests : AbstractDbTest
|
|||
s.Metadata.CollectionTags.Add(new CollectionTag()
|
||||
{
|
||||
Title = "Something 2",
|
||||
NormalizedTitle = "Something 2".ToNormalized(),
|
||||
CoverImage = $"{ImageService.GetCollectionTagFormat(2)}.jpg"
|
||||
});
|
||||
s.CoverImage = $"{ImageService.GetSeriesFormat(3)}.jpg";
|
||||
|
|
@ -250,14 +250,16 @@ public class CleanupServiceTests : AbstractDbTest
|
|||
new ReadingList()
|
||||
{
|
||||
Title = "Something",
|
||||
NormalizedTitle = API.Services.Tasks.Scanner.Parser.Parser.Normalize("Something"),
|
||||
CoverImage = $"{ImageService.GetReadingListFormat(1)}.jpg"
|
||||
NormalizedTitle = "Something".ToNormalized(),
|
||||
CoverImage = $"{ImageService.GetReadingListFormat(1)}.jpg",
|
||||
AgeRating = AgeRating.Unknown
|
||||
},
|
||||
new ReadingList()
|
||||
{
|
||||
Title = "Something 2",
|
||||
NormalizedTitle = API.Services.Tasks.Scanner.Parser.Parser.Normalize("Something 2"),
|
||||
CoverImage = $"{ImageService.GetReadingListFormat(2)}.jpg"
|
||||
NormalizedTitle = "Something 2".ToNormalized(),
|
||||
CoverImage = $"{ImageService.GetReadingListFormat(2)}.jpg",
|
||||
AgeRating = AgeRating.Unknown
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -408,22 +410,25 @@ public class CleanupServiceTests : AbstractDbTest
|
|||
[Fact]
|
||||
public async Task CleanupDbEntries_CleanupAbandonedChapters()
|
||||
{
|
||||
var c = EntityFactory.CreateChapter("1", false, new List<MangaFile>(), 1);
|
||||
_context.Series.Add(new Series()
|
||||
var c = new ChapterBuilder("0")
|
||||
.WithPages(1)
|
||||
.Build();
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithFormat(MangaFormat.Epub)
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithNumber(1)
|
||||
.WithChapter(c)
|
||||
.Build())
|
||||
.Build();
|
||||
series.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library() {
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
},
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
c,
|
||||
}),
|
||||
}
|
||||
});
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
};
|
||||
|
||||
_context.Series.Add(series);
|
||||
|
||||
|
||||
_context.AppUser.Add(new AppUser()
|
||||
{
|
||||
|
|
@ -461,25 +466,19 @@ public class CleanupServiceTests : AbstractDbTest
|
|||
{
|
||||
var c = new CollectionTag()
|
||||
{
|
||||
Title = "Test Tag"
|
||||
Title = "Test Tag",
|
||||
NormalizedTitle = "Test Tag".ToNormalized(),
|
||||
};
|
||||
var s = new Series()
|
||||
var s = new SeriesBuilder("Test")
|
||||
.WithFormat(MangaFormat.Epub)
|
||||
.WithMetadata(new SeriesMetadataBuilder().WithCollectionTag(c).Build())
|
||||
.Build();
|
||||
s.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
},
|
||||
Volumes = new List<Volume>(),
|
||||
Metadata = new SeriesMetadata()
|
||||
{
|
||||
CollectionTags = new List<CollectionTag>()
|
||||
{
|
||||
c
|
||||
}
|
||||
}
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
};
|
||||
|
||||
_context.Series.Add(s);
|
||||
|
||||
_context.AppUser.Add(new AppUser()
|
||||
|
|
@ -511,19 +510,14 @@ public class CleanupServiceTests : AbstractDbTest
|
|||
{
|
||||
await ResetDb();
|
||||
|
||||
var s = new Series()
|
||||
var s = new SeriesBuilder("Test CleanupWantToRead_ShouldRemoveFullyReadSeries")
|
||||
.WithMetadata(new SeriesMetadataBuilder().WithPublicationStatus(PublicationStatus.Completed).Build())
|
||||
.Build();
|
||||
|
||||
s.Library = new Library()
|
||||
{
|
||||
Name = "Test CleanupWantToRead_ShouldRemoveFullyReadSeries",
|
||||
Library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
},
|
||||
Volumes = new List<Volume>(),
|
||||
Metadata = new SeriesMetadata()
|
||||
{
|
||||
PublicationStatus = PublicationStatus.Completed
|
||||
}
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
};
|
||||
_context.Series.Add(s);
|
||||
|
||||
|
|
|
|||
|
|
@ -2,14 +2,13 @@
|
|||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.Data;
|
||||
using API.Data.Repositories;
|
||||
using API.DTOs.CollectionTags;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Services;
|
||||
using API.Services.Tasks.Metadata;
|
||||
using API.SignalR;
|
||||
using API.Tests.Helpers;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
||||
|
|
@ -87,7 +86,7 @@ public class CollectionTagServiceTests : AbstractDbTest
|
|||
{
|
||||
await SeedSeries();
|
||||
var ids = new[] {1, 2};
|
||||
await _service.AddTagToSeries(await _unitOfWork.CollectionTagRepository.GetFullTagAsync(1), ids);
|
||||
await _service.AddTagToSeries(await _unitOfWork.CollectionTagRepository.GetTagAsync(1, CollectionTagIncludes.SeriesMetadata), ids);
|
||||
|
||||
var metadatas = await _unitOfWork.SeriesRepository.GetSeriesMetadataForIdsAsync(ids);
|
||||
Assert.True(metadatas.ElementAt(0).CollectionTags.Any(t => t.Title.Equals("Tag 1")));
|
||||
|
|
@ -99,7 +98,7 @@ public class CollectionTagServiceTests : AbstractDbTest
|
|||
{
|
||||
await SeedSeries();
|
||||
var ids = new[] {1, 2};
|
||||
var tag = await _unitOfWork.CollectionTagRepository.GetFullTagAsync(2);
|
||||
var tag = await _unitOfWork.CollectionTagRepository.GetTagAsync(2, CollectionTagIncludes.SeriesMetadata);
|
||||
await _service.AddTagToSeries(tag, ids);
|
||||
|
||||
await _service.RemoveTagFromSeries(tag, new[] {1});
|
||||
|
|
|
|||
|
|
@ -5,7 +5,6 @@ using API.DTOs.Device;
|
|||
using API.Entities;
|
||||
using API.Entities.Enums.Device;
|
||||
using API.Services;
|
||||
using API.Services.Tasks;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ public class DirectoryServiceTests
|
|||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), fileSystem);
|
||||
var files = ds.GetFiles(testDirectory, API.Services.Tasks.Scanner.Parser.Parser.ArchiveFileExtensions).ToList();
|
||||
|
||||
Assert.Equal(10, files.Count());
|
||||
Assert.Equal(10, files.Count);
|
||||
Assert.All(files, s => fileSystem.Path.GetExtension(s).Equals(".zip"));
|
||||
}
|
||||
|
||||
|
|
@ -171,7 +171,7 @@ public class DirectoryServiceTests
|
|||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), fileSystem);
|
||||
var files = ds.GetFiles(testDirectory).ToList();
|
||||
|
||||
Assert.Equal(11, files.Count());
|
||||
Assert.Equal(11, files.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -189,7 +189,7 @@ public class DirectoryServiceTests
|
|||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), fileSystem);
|
||||
var files = ds.GetFiles(testDirectory).ToList();
|
||||
|
||||
Assert.Equal(11, files.Count());
|
||||
Assert.Equal(11, files.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -207,7 +207,7 @@ public class DirectoryServiceTests
|
|||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), fileSystem);
|
||||
var files = ds.GetFiles(testDirectory).ToList();
|
||||
|
||||
Assert.Equal(10, files.Count());
|
||||
Assert.Equal(10, files.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -225,7 +225,7 @@ public class DirectoryServiceTests
|
|||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), fileSystem);
|
||||
var files = ds.GetFiles(testDirectory).ToList();
|
||||
|
||||
Assert.Equal(10, files.Count());
|
||||
Assert.Equal(10, files.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -243,7 +243,7 @@ public class DirectoryServiceTests
|
|||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), fileSystem);
|
||||
var files = ds.GetFiles(testDirectory).ToList();
|
||||
|
||||
Assert.Equal(10, files.Count());
|
||||
Assert.Equal(10, files.Count);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -325,7 +325,7 @@ public class DirectoryServiceTests
|
|||
ds.CopyFileToDirectory($"{testDirectory}file/data-0.txt", "/manga/output/");
|
||||
Assert.True(fileSystem.FileExists("/manga/output/data-0.txt"));
|
||||
Assert.True(fileSystem.FileExists("/manga/file/data-0.txt"));
|
||||
Assert.True(fileSystem.FileInfo.FromFileName("/manga/file/data-0.txt").Length == fileSystem.FileInfo.FromFileName("/manga/output/data-0.txt").Length);
|
||||
Assert.True(fileSystem.FileInfo.New("/manga/file/data-0.txt").Length == fileSystem.FileInfo.New("/manga/output/data-0.txt").Length);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
@ -353,7 +353,7 @@ public class DirectoryServiceTests
|
|||
|
||||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), fileSystem);
|
||||
ds.CopyDirectoryToDirectory($"{testDirectory}empty/", "/manga/output/");
|
||||
Assert.Empty(fileSystem.DirectoryInfo.FromDirectoryName("/manga/output/").GetFiles());
|
||||
Assert.Empty(fileSystem.DirectoryInfo.New("/manga/output/").GetFiles());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -427,7 +427,7 @@ public class DirectoryServiceTests
|
|||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), fileSystem);
|
||||
ds.ExistOrCreate("c:/manga/output/");
|
||||
|
||||
Assert.True(ds.FileSystem.DirectoryInfo.FromDirectoryName("c:/manga/output/").Exists);
|
||||
Assert.True(ds.FileSystem.DirectoryInfo.New("c:/manga/output/").Exists);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
@ -448,9 +448,9 @@ public class DirectoryServiceTests
|
|||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), fileSystem);
|
||||
ds.ClearAndDeleteDirectory($"{testDirectory}");
|
||||
Assert.Empty(ds.GetFiles("/manga/", searchOption: SearchOption.AllDirectories));
|
||||
Assert.Empty(ds.FileSystem.DirectoryInfo.FromDirectoryName("/manga/").GetDirectories());
|
||||
Assert.True(ds.FileSystem.DirectoryInfo.FromDirectoryName("/manga/").Exists);
|
||||
Assert.False(ds.FileSystem.DirectoryInfo.FromDirectoryName("/manga/base").Exists);
|
||||
Assert.Empty(ds.FileSystem.DirectoryInfo.New("/manga/").GetDirectories());
|
||||
Assert.True(ds.FileSystem.DirectoryInfo.New("/manga/").Exists);
|
||||
Assert.False(ds.FileSystem.DirectoryInfo.New("/manga/base").Exists);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
@ -470,9 +470,9 @@ public class DirectoryServiceTests
|
|||
|
||||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), fileSystem);
|
||||
ds.ClearDirectory($"{testDirectory}file/");
|
||||
Assert.Empty(ds.FileSystem.DirectoryInfo.FromDirectoryName($"{testDirectory}file/").GetDirectories());
|
||||
Assert.True(ds.FileSystem.DirectoryInfo.FromDirectoryName("/manga/").Exists);
|
||||
Assert.True(ds.FileSystem.DirectoryInfo.FromDirectoryName($"{testDirectory}file/").Exists);
|
||||
Assert.Empty(ds.FileSystem.DirectoryInfo.New($"{testDirectory}file/").GetDirectories());
|
||||
Assert.True(ds.FileSystem.DirectoryInfo.New("/manga/").Exists);
|
||||
Assert.True(ds.FileSystem.DirectoryInfo.New($"{testDirectory}file/").Exists);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -487,9 +487,9 @@ public class DirectoryServiceTests
|
|||
|
||||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), fileSystem);
|
||||
ds.ClearDirectory($"{testDirectory}");
|
||||
Assert.Empty(ds.FileSystem.DirectoryInfo.FromDirectoryName($"{testDirectory}").GetDirectories());
|
||||
Assert.True(ds.FileSystem.DirectoryInfo.FromDirectoryName(testDirectory).Exists);
|
||||
Assert.False(ds.FileSystem.DirectoryInfo.FromDirectoryName($"{testDirectory}file/").Exists);
|
||||
Assert.Empty(ds.FileSystem.DirectoryInfo.New($"{testDirectory}").GetDirectories());
|
||||
Assert.True(ds.FileSystem.DirectoryInfo.New(testDirectory).Exists);
|
||||
Assert.False(ds.FileSystem.DirectoryInfo.New($"{testDirectory}file/").Exists);
|
||||
}
|
||||
#endregion
|
||||
|
||||
|
|
@ -587,7 +587,7 @@ public class DirectoryServiceTests
|
|||
ds.CopyFilesToDirectory(new []{MockUnixSupport.Path($"{testDirectory}file.zip")}, "/manga/output/");
|
||||
ds.CopyFilesToDirectory(new []{MockUnixSupport.Path($"{testDirectory}file.zip")}, "/manga/output/");
|
||||
var outputFiles = ds.GetFiles("/manga/output/").Select(API.Services.Tasks.Scanner.Parser.Parser.NormalizePath).ToList();
|
||||
Assert.Equal(4, outputFiles.Count()); // we have 2 already there and 2 copies
|
||||
Assert.Equal(4, outputFiles.Count); // we have 2 already there and 2 copies
|
||||
// For some reason, this has C:/ on directory even though everything is emulated (System.IO.Abstractions issue, not changing)
|
||||
// https://github.com/TestableIO/System.IO.Abstractions/issues/831
|
||||
Assert.True(outputFiles.Contains(API.Services.Tasks.Scanner.Parser.Parser.NormalizePath("/manga/output/file (3).zip"))
|
||||
|
|
@ -645,10 +645,10 @@ public class DirectoryServiceTests
|
|||
const string testDirectory = "/manga/";
|
||||
var fileSystem = new MockFileSystem();
|
||||
fileSystem.AddDirectory($"{testDirectory}dir1");
|
||||
var di = fileSystem.DirectoryInfo.FromDirectoryName($"{testDirectory}dir1");
|
||||
var di = fileSystem.DirectoryInfo.New($"{testDirectory}dir1");
|
||||
di.Attributes |= FileAttributes.System;
|
||||
fileSystem.AddDirectory($"{testDirectory}dir2");
|
||||
di = fileSystem.DirectoryInfo.FromDirectoryName($"{testDirectory}dir2");
|
||||
di = fileSystem.DirectoryInfo.New($"{testDirectory}dir2");
|
||||
di.Attributes |= FileAttributes.Hidden;
|
||||
fileSystem.AddDirectory($"{testDirectory}dir3");
|
||||
fileSystem.AddFile($"{testDirectory}file_0.zip", new MockFileData(""));
|
||||
|
|
|
|||
|
|
@ -1,5 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Concurrent;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
|
|
@ -9,15 +8,13 @@ using API.Data;
|
|||
using API.Data.Metadata;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Extensions;
|
||||
using API.Parser;
|
||||
using API.Services;
|
||||
using API.Services.Tasks.Scanner;
|
||||
using API.Services.Tasks.Scanner.Parser;
|
||||
using API.SignalR;
|
||||
using API.Tests.Helpers;
|
||||
using AutoMapper;
|
||||
using DotNet.Globbing;
|
||||
using Flurl.Util;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
|
|
@ -254,7 +251,7 @@ public class ParseScannedFilesTests
|
|||
var foundParsedSeries = new ParsedSeries()
|
||||
{
|
||||
Name = parsedFiles.First().Series,
|
||||
NormalizedName = API.Services.Tasks.Scanner.Parser.Parser.Normalize(parsedFiles.First().Series),
|
||||
NormalizedName = parsedFiles.First().Series.ToNormalized(),
|
||||
Format = parsedFiles.First().Format
|
||||
};
|
||||
|
||||
|
|
|
|||
File diff suppressed because it is too large
Load diff
|
|
@ -11,10 +11,12 @@ using API.DTOs.ReadingLists;
|
|||
using API.DTOs.ReadingLists.CBL;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Extensions;
|
||||
using API.Helpers;
|
||||
using API.Services;
|
||||
using API.SignalR;
|
||||
using API.Tests.Helpers;
|
||||
using API.Tests.Helpers.Builders;
|
||||
using AutoMapper;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
|
@ -44,7 +46,7 @@ public class ReadingListServiceTests
|
|||
|
||||
var config = new MapperConfiguration(cfg => cfg.AddProfile<AutoMapperProfiles>());
|
||||
var mapper = config.CreateMapper();
|
||||
_unitOfWork = new UnitOfWork(_context, mapper, null);
|
||||
_unitOfWork = new UnitOfWork(_context, mapper, null!);
|
||||
|
||||
_readingListService = new ReadingListService(_unitOfWork, Substitute.For<ILogger<ReadingListService>>(), Substitute.For<IEventHub>());
|
||||
}
|
||||
|
|
@ -124,36 +126,26 @@ public class ReadingListServiceTests
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>()),
|
||||
Volumes = new List<Volume>()
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(DbFactory.SeriesMetadata(new List<CollectionTag>()))
|
||||
.WithVolumes(new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Name = "0",
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
Number = "1",
|
||||
AgeRating = AgeRating.Everyone,
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "2",
|
||||
AgeRating = AgeRating.X18Plus
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "3",
|
||||
AgeRating = AgeRating.X18Plus
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("1")
|
||||
.WithAgeRating(AgeRating.Everyone)
|
||||
.Build()
|
||||
)
|
||||
.WithChapter(new ChapterBuilder("2")
|
||||
.WithAgeRating(AgeRating.X18Plus)
|
||||
.Build()
|
||||
)
|
||||
.WithChapter(new ChapterBuilder("3")
|
||||
.WithAgeRating(AgeRating.X18Plus)
|
||||
.Build()
|
||||
)
|
||||
.Build()
|
||||
})
|
||||
.Build(),
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
@ -162,8 +154,8 @@ public class ReadingListServiceTests
|
|||
await _context.SaveChangesAsync();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists);
|
||||
var readingList = new ReadingList();
|
||||
user.ReadingLists = new List<ReadingList>()
|
||||
var readingList = DbFactory.ReadingList("test");
|
||||
user!.ReadingLists = new List<ReadingList>()
|
||||
{
|
||||
readingList
|
||||
};
|
||||
|
|
@ -191,36 +183,26 @@ public class ReadingListServiceTests
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>()),
|
||||
Volumes = new List<Volume>()
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(DbFactory.SeriesMetadata(new List<CollectionTag>()))
|
||||
.WithVolumes(new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Name = "0",
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
Number = "1",
|
||||
AgeRating = AgeRating.Everyone,
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "2",
|
||||
AgeRating = AgeRating.X18Plus
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "3",
|
||||
AgeRating = AgeRating.X18Plus
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("1")
|
||||
.WithAgeRating(AgeRating.Everyone)
|
||||
.Build()
|
||||
)
|
||||
.WithChapter(new ChapterBuilder("2")
|
||||
.WithAgeRating(AgeRating.X18Plus)
|
||||
.Build()
|
||||
)
|
||||
.WithChapter(new ChapterBuilder("3")
|
||||
.WithAgeRating(AgeRating.X18Plus)
|
||||
.Build()
|
||||
)
|
||||
.Build()
|
||||
})
|
||||
.Build()
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
@ -229,8 +211,8 @@ public class ReadingListServiceTests
|
|||
await _context.SaveChangesAsync();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists);
|
||||
var readingList = new ReadingList();
|
||||
user.ReadingLists = new List<ReadingList>()
|
||||
var readingList = DbFactory.ReadingList("test");
|
||||
user!.ReadingLists = new List<ReadingList>()
|
||||
{
|
||||
readingList
|
||||
};
|
||||
|
|
@ -265,36 +247,26 @@ public class ReadingListServiceTests
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>()),
|
||||
Volumes = new List<Volume>()
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(DbFactory.SeriesMetadata(new List<CollectionTag>()))
|
||||
.WithVolumes(new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Name = "0",
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
Number = "1",
|
||||
AgeRating = AgeRating.Everyone,
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "2",
|
||||
AgeRating = AgeRating.X18Plus
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "3",
|
||||
AgeRating = AgeRating.X18Plus
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("1")
|
||||
.WithAgeRating(AgeRating.Everyone)
|
||||
.Build()
|
||||
)
|
||||
.WithChapter(new ChapterBuilder("2")
|
||||
.WithAgeRating(AgeRating.X18Plus)
|
||||
.Build()
|
||||
)
|
||||
.WithChapter(new ChapterBuilder("3")
|
||||
.WithAgeRating(AgeRating.X18Plus)
|
||||
.Build()
|
||||
)
|
||||
.Build()
|
||||
})
|
||||
.Build()
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
@ -303,7 +275,7 @@ public class ReadingListServiceTests
|
|||
await _context.SaveChangesAsync();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists);
|
||||
var readingList = new ReadingList();
|
||||
var readingList = DbFactory.ReadingList("Test");
|
||||
user.ReadingLists = new List<ReadingList>()
|
||||
{
|
||||
readingList
|
||||
|
|
@ -341,36 +313,26 @@ public class ReadingListServiceTests
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>()),
|
||||
Volumes = new List<Volume>()
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(DbFactory.SeriesMetadata(new List<CollectionTag>()))
|
||||
.WithVolumes(new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Name = "0",
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
Number = "1",
|
||||
AgeRating = AgeRating.Everyone,
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "2",
|
||||
AgeRating = AgeRating.X18Plus
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "3",
|
||||
AgeRating = AgeRating.X18Plus
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("1")
|
||||
.WithAgeRating(AgeRating.Everyone)
|
||||
.Build()
|
||||
)
|
||||
.WithChapter(new ChapterBuilder("2")
|
||||
.WithAgeRating(AgeRating.X18Plus)
|
||||
.Build()
|
||||
)
|
||||
.WithChapter(new ChapterBuilder("3")
|
||||
.WithAgeRating(AgeRating.X18Plus)
|
||||
.Build()
|
||||
)
|
||||
.Build()
|
||||
})
|
||||
.Build()
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
@ -379,8 +341,8 @@ public class ReadingListServiceTests
|
|||
await _context.SaveChangesAsync();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists);
|
||||
var readingList = new ReadingList();
|
||||
user.ReadingLists = new List<ReadingList>()
|
||||
var readingList = DbFactory.ReadingList("test");
|
||||
user!.ReadingLists = new List<ReadingList>()
|
||||
{
|
||||
readingList
|
||||
};
|
||||
|
|
@ -436,31 +398,22 @@ public class ReadingListServiceTests
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>()),
|
||||
Volumes = new List<Volume>()
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(DbFactory.SeriesMetadata(new List<CollectionTag>()))
|
||||
.WithVolumes(new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Name = "0",
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
Number = "1",
|
||||
AgeRating = AgeRating.Everyone
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "2",
|
||||
AgeRating = AgeRating.X18Plus
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("1")
|
||||
.WithAgeRating(AgeRating.Everyone)
|
||||
.Build()
|
||||
)
|
||||
.WithChapter(new ChapterBuilder("2")
|
||||
.WithAgeRating(AgeRating.X18Plus)
|
||||
.Build()
|
||||
)
|
||||
.Build()
|
||||
})
|
||||
.Build(),
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
@ -469,7 +422,7 @@ public class ReadingListServiceTests
|
|||
await _context.SaveChangesAsync();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists);
|
||||
var readingList = new ReadingList();
|
||||
var readingList = DbFactory.ReadingList("Test");
|
||||
user.ReadingLists = new List<ReadingList>()
|
||||
{
|
||||
readingList
|
||||
|
|
@ -508,39 +461,26 @@ public class ReadingListServiceTests
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>()),
|
||||
Volumes = new List<Volume>()
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(DbFactory.SeriesMetadata(new List<CollectionTag>()))
|
||||
.WithVolumes(new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Name = "0",
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
Number = "1",
|
||||
AgeRating = AgeRating.Everyone,
|
||||
Pages = 1
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "2",
|
||||
AgeRating = AgeRating.X18Plus,
|
||||
Pages = 1
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "3",
|
||||
AgeRating = AgeRating.X18Plus,
|
||||
Pages = 1
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("1")
|
||||
.WithAgeRating(AgeRating.Everyone)
|
||||
.Build()
|
||||
)
|
||||
.WithChapter(new ChapterBuilder("2")
|
||||
.WithAgeRating(AgeRating.X18Plus)
|
||||
.Build()
|
||||
)
|
||||
.WithChapter(new ChapterBuilder("3")
|
||||
.WithAgeRating(AgeRating.X18Plus)
|
||||
.Build()
|
||||
)
|
||||
.Build()
|
||||
})
|
||||
.Build()
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
@ -549,7 +489,7 @@ public class ReadingListServiceTests
|
|||
await _context.SaveChangesAsync();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists | AppUserIncludes.Progress);
|
||||
var readingList = new ReadingList();
|
||||
var readingList = DbFactory.ReadingList("Test");
|
||||
user.ReadingLists = new List<ReadingList>()
|
||||
{
|
||||
readingList
|
||||
|
|
@ -594,29 +534,20 @@ public class ReadingListServiceTests
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>()),
|
||||
Volumes = new List<Volume>()
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(DbFactory.SeriesMetadata(new List<CollectionTag>()))
|
||||
.WithVolumes(new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Name = "0",
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
Number = "1",
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "2",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("1")
|
||||
.Build()
|
||||
)
|
||||
.WithChapter(new ChapterBuilder("2")
|
||||
.Build()
|
||||
)
|
||||
.Build()
|
||||
})
|
||||
.Build()
|
||||
}
|
||||
},
|
||||
}
|
||||
|
|
@ -625,8 +556,8 @@ public class ReadingListServiceTests
|
|||
await _context.SaveChangesAsync();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists);
|
||||
var readingList = new ReadingList();
|
||||
user.ReadingLists = new List<ReadingList>()
|
||||
var readingList = DbFactory.ReadingList("Test");
|
||||
user!.ReadingLists = new List<ReadingList>()
|
||||
{
|
||||
readingList
|
||||
};
|
||||
|
|
@ -645,29 +576,20 @@ public class ReadingListServiceTests
|
|||
public async Task CalculateAgeRating_ShouldUpdateToMax()
|
||||
{
|
||||
await ResetDb();
|
||||
var s = new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>()),
|
||||
Volumes = new List<Volume>()
|
||||
var s = new SeriesBuilder("Test")
|
||||
.WithMetadata(DbFactory.SeriesMetadata(new List<CollectionTag>()))
|
||||
.WithVolumes(new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Name = "0",
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
Number = "1",
|
||||
},
|
||||
new Chapter()
|
||||
{
|
||||
Number = "2",
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("1")
|
||||
.Build()
|
||||
)
|
||||
.WithChapter(new ChapterBuilder("2")
|
||||
.Build()
|
||||
)
|
||||
.Build()
|
||||
})
|
||||
.Build();
|
||||
_context.AppUser.Add(new AppUser()
|
||||
{
|
||||
UserName = "majora2007",
|
||||
|
|
@ -691,7 +613,7 @@ public class ReadingListServiceTests
|
|||
await _context.SaveChangesAsync();
|
||||
|
||||
var user = await _unitOfWork.UserRepository.GetUserByUsernameAsync("majora2007", AppUserIncludes.ReadingLists);
|
||||
var readingList = new ReadingList();
|
||||
var readingList = DbFactory.ReadingList("Test");
|
||||
user.ReadingLists = new List<ReadingList>()
|
||||
{
|
||||
readingList
|
||||
|
|
@ -1108,33 +1030,53 @@ public class ReadingListServiceTests
|
|||
var cblReadingList = LoadCblFromPath("Fables.cbl");
|
||||
|
||||
// Mock up our series
|
||||
var fablesSeries = DbFactory.Series("Fables");
|
||||
var fables2Series = DbFactory.Series("Fables: The Last Castle");
|
||||
// var fablesSeries = DbFactory.Series("Fables");
|
||||
// var fables2Series = DbFactory.Series("Fables: The Last Castle");
|
||||
|
||||
fablesSeries.Volumes.Add(new Volume()
|
||||
{
|
||||
Number = 1,
|
||||
Name = "2002",
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", false),
|
||||
EntityFactory.CreateChapter("2", false),
|
||||
EntityFactory.CreateChapter("3", false),
|
||||
var fablesSeries = new SeriesBuilder("Fables")
|
||||
.WithVolume(new VolumeBuilder("2002")
|
||||
.WithNumber(1)
|
||||
.WithChapter(new ChapterBuilder("1").Build())
|
||||
.WithChapter(new ChapterBuilder("2").Build())
|
||||
.WithChapter(new ChapterBuilder("3").Build())
|
||||
.Build())
|
||||
.Build();
|
||||
|
||||
}
|
||||
});
|
||||
fables2Series.Volumes.Add(new Volume()
|
||||
{
|
||||
Number = 1,
|
||||
Name = "2003",
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", false),
|
||||
EntityFactory.CreateChapter("2", false),
|
||||
EntityFactory.CreateChapter("3", false),
|
||||
var fables2Series = new SeriesBuilder("Fables: The Last Castle")
|
||||
.WithVolume(new VolumeBuilder("2003")
|
||||
.WithNumber(1)
|
||||
.WithChapter(new ChapterBuilder("1").Build())
|
||||
.WithChapter(new ChapterBuilder("2").Build())
|
||||
.WithChapter(new ChapterBuilder("3").Build())
|
||||
.Build())
|
||||
.Build();
|
||||
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
// fablesSeries.Volumes.Add(new Volume()
|
||||
// {
|
||||
// Number = 1,
|
||||
// Name = "2002",
|
||||
// Chapters = new List<Chapter>()
|
||||
// {
|
||||
// EntityFactory.CreateChapter("1", false),
|
||||
// EntityFactory.CreateChapter("2", false),
|
||||
// EntityFactory.CreateChapter("3", false),
|
||||
//
|
||||
// }
|
||||
// });
|
||||
// fables2Series.Volumes.Add(new Volume()
|
||||
// {
|
||||
// Number = 1,
|
||||
// Name = "2003",
|
||||
// Chapters = new List<Chapter>()
|
||||
// {
|
||||
// EntityFactory.CreateChapter("1", false),
|
||||
// EntityFactory.CreateChapter("2", false),
|
||||
// EntityFactory.CreateChapter("3", false),
|
||||
//
|
||||
// }
|
||||
// });
|
||||
|
||||
_context.AppUser.Add(new AppUser()
|
||||
{
|
||||
|
|
|
|||
|
|
@ -3,10 +3,12 @@ using System.Linq;
|
|||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Entities.Metadata;
|
||||
using API.Extensions;
|
||||
using API.Parser;
|
||||
using API.Services.Tasks;
|
||||
using API.Services.Tasks.Scanner;
|
||||
using API.Tests.Helpers;
|
||||
using API.Tests.Helpers.Builders;
|
||||
using Xunit;
|
||||
|
||||
namespace API.Tests.Services;
|
||||
|
|
@ -23,23 +25,14 @@ public class ScannerServiceTests
|
|||
|
||||
var existingSeries = new List<Series>
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Darker Than Black",
|
||||
LocalizedName = "Darker Than Black",
|
||||
OriginalName = "Darker Than Black",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
{
|
||||
Number = 1,
|
||||
Name = "1"
|
||||
}
|
||||
},
|
||||
NormalizedName = API.Services.Tasks.Scanner.Parser.Parser.Normalize("Darker Than Black"),
|
||||
Metadata = new SeriesMetadata(),
|
||||
Format = MangaFormat.Epub
|
||||
}
|
||||
new SeriesBuilder("Darker Than Black")
|
||||
.WithFormat(MangaFormat.Epub)
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithName("1")
|
||||
.Build())
|
||||
.WithLocalizedName("Darker Than Black")
|
||||
.Build()
|
||||
};
|
||||
|
||||
Assert.Equal(1, ScannerService.FindSeriesNotOnDisk(existingSeries, infos).Count());
|
||||
|
|
@ -56,76 +49,42 @@ public class ScannerServiceTests
|
|||
|
||||
var existingSeries = new List<Series>
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Cage of Eden",
|
||||
LocalizedName = "Cage of Eden",
|
||||
OriginalName = "Cage of Eden",
|
||||
NormalizedName = API.Services.Tasks.Scanner.Parser.Parser.Normalize("Cage of Eden"),
|
||||
Metadata = new SeriesMetadata(),
|
||||
Format = MangaFormat.Archive
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Darker Than Black",
|
||||
LocalizedName = "Darker Than Black",
|
||||
OriginalName = "Darker Than Black",
|
||||
NormalizedName = API.Services.Tasks.Scanner.Parser.Parser.Normalize("Darker Than Black"),
|
||||
Metadata = new SeriesMetadata(),
|
||||
Format = MangaFormat.Archive
|
||||
}
|
||||
new SeriesBuilder("Cage of Eden")
|
||||
.WithFormat(MangaFormat.Archive)
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithName("1")
|
||||
.Build())
|
||||
.WithLocalizedName("Darker Than Black")
|
||||
.Build(),
|
||||
new SeriesBuilder("Darker Than Black")
|
||||
.WithFormat(MangaFormat.Archive)
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithName("1")
|
||||
.Build())
|
||||
.WithLocalizedName("Darker Than Black")
|
||||
.Build(),
|
||||
// new Series()
|
||||
// {
|
||||
// Name = "Cage of Eden",
|
||||
// LocalizedName = "Cage of Eden",
|
||||
// OriginalName = "Cage of Eden",
|
||||
// NormalizedName = "Darker Than Black".ToNormalized(),
|
||||
// Metadata = new SeriesMetadata(),
|
||||
// Format = MangaFormat.Archive
|
||||
// },
|
||||
// new Series()
|
||||
// {
|
||||
// Name = "Darker Than Black",
|
||||
// LocalizedName = "Darker Than Black",
|
||||
// OriginalName = "Darker Than Black",
|
||||
// NormalizedName = "Darker Than Black".ToNormalized(),
|
||||
// Metadata = new SeriesMetadata(),
|
||||
// Format = MangaFormat.Archive
|
||||
// }
|
||||
};
|
||||
|
||||
|
||||
|
||||
Assert.Empty(ScannerService.FindSeriesNotOnDisk(existingSeries, infos));
|
||||
}
|
||||
|
||||
|
||||
// TODO: Figure out how to do this with ParseScannedFiles
|
||||
// [Theory]
|
||||
// [InlineData(new [] {"Darker than Black"}, "Darker than Black", "Darker than Black")]
|
||||
// [InlineData(new [] {"Darker than Black"}, "Darker Than Black", "Darker than Black")]
|
||||
// [InlineData(new [] {"Darker than Black"}, "Darker Than Black!", "Darker than Black")]
|
||||
// [InlineData(new [] {""}, "Runaway Jack", "Runaway Jack")]
|
||||
// public void MergeNameTest(string[] existingSeriesNames, string parsedInfoName, string expected)
|
||||
// {
|
||||
// var collectedSeries = new ConcurrentDictionary<ParsedSeries, List<ParserInfo>>();
|
||||
// foreach (var seriesName in existingSeriesNames)
|
||||
// {
|
||||
// AddToParsedInfo(collectedSeries, new ParserInfo() {Series = seriesName, Format = MangaFormat.Archive});
|
||||
// }
|
||||
//
|
||||
// var actualName = new ParseScannedFiles(_bookService, _logger).MergeName(collectedSeries, new ParserInfo()
|
||||
// {
|
||||
// Series = parsedInfoName,
|
||||
// Format = MangaFormat.Archive
|
||||
// });
|
||||
//
|
||||
// Assert.Equal(expected, actualName);
|
||||
// }
|
||||
|
||||
// [Fact]
|
||||
// public void RemoveMissingSeries_Should_RemoveSeries()
|
||||
// {
|
||||
// var existingSeries = new List<Series>()
|
||||
// {
|
||||
// EntityFactory.CreateSeries("Darker than Black Vol 1"),
|
||||
// EntityFactory.CreateSeries("Darker than Black"),
|
||||
// EntityFactory.CreateSeries("Beastars"),
|
||||
// };
|
||||
// var missingSeries = new List<Series>()
|
||||
// {
|
||||
// EntityFactory.CreateSeries("Darker than Black Vol 1"),
|
||||
// };
|
||||
// existingSeries = ScannerService.RemoveMissingSeries(existingSeries, missingSeries, out var removeCount).ToList();
|
||||
//
|
||||
// Assert.DoesNotContain(missingSeries[0].Name, existingSeries.Select(s => s.Name));
|
||||
// Assert.Equal(missingSeries.Count, removeCount);
|
||||
// }
|
||||
|
||||
|
||||
// TODO: I want a test for UpdateSeries where if I have chapter 10 and now it's mapping into Vol 2 Chapter 10,
|
||||
// if I can do it without deleting the underlying chapter (aka id change)
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.Data;
|
||||
|
|
@ -14,14 +12,10 @@ using API.Entities;
|
|||
using API.Entities.Enums;
|
||||
using API.Entities.Metadata;
|
||||
using API.Extensions;
|
||||
using API.Helpers;
|
||||
using API.Services;
|
||||
using API.SignalR;
|
||||
using API.Tests.Helpers;
|
||||
using AutoMapper;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using API.Tests.Helpers.Builders;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
|
|
@ -93,28 +87,22 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("Omake", true, new List<MangaFile>()),
|
||||
EntityFactory.CreateChapter("Something SP02", true, new List<MangaFile>()),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("21", false, new List<MangaFile>()),
|
||||
EntityFactory.CreateChapter("22", false, new List<MangaFile>()),
|
||||
}),
|
||||
EntityFactory.CreateVolume("3", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("31", false, new List<MangaFile>()),
|
||||
EntityFactory.CreateChapter("32", false, new List<MangaFile>()),
|
||||
}),
|
||||
}
|
||||
}
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("Omake").WithIsSpecial(true).WithTitle("Omake").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("Something SP02").WithIsSpecial(true).WithTitle("Something").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("21").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("21").WithPages(1).Build())
|
||||
.Build())
|
||||
|
||||
.WithVolume(new VolumeBuilder("3")
|
||||
.WithChapter(new ChapterBuilder("31").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("32").WithPages(1).Build())
|
||||
.Build())
|
||||
.Build(),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -147,28 +135,22 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Manga,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", false, new List<MangaFile>()),
|
||||
EntityFactory.CreateChapter("2", false, new List<MangaFile>()),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("21", false, new List<MangaFile>()),
|
||||
EntityFactory.CreateChapter("22", false, new List<MangaFile>()),
|
||||
}),
|
||||
EntityFactory.CreateVolume("3", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("31", false, new List<MangaFile>()),
|
||||
EntityFactory.CreateChapter("32", false, new List<MangaFile>()),
|
||||
}),
|
||||
}
|
||||
}
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("1").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("2").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("21").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("21").WithPages(1).Build())
|
||||
.Build())
|
||||
|
||||
.WithVolume(new VolumeBuilder("3")
|
||||
.WithChapter(new ChapterBuilder("31").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("32").WithPages(1).Build())
|
||||
.Build())
|
||||
.Build(),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -201,26 +183,20 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Manga,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", false, new List<MangaFile>()),
|
||||
EntityFactory.CreateChapter("2", false, new List<MangaFile>()),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("0", false, new List<MangaFile>()),
|
||||
}),
|
||||
EntityFactory.CreateVolume("3", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("31", false, new List<MangaFile>()),
|
||||
}),
|
||||
}
|
||||
}
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("1").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("2").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("0").WithPages(1).Build())
|
||||
.Build())
|
||||
|
||||
.WithVolume(new VolumeBuilder("3")
|
||||
.WithChapter(new ChapterBuilder("31").WithPages(1).Build())
|
||||
.Build())
|
||||
.Build(),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -253,26 +229,20 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Manga,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", false, new List<MangaFile>()),
|
||||
EntityFactory.CreateChapter("2", false, new List<MangaFile>()),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("0", false, new List<MangaFile>()),
|
||||
}),
|
||||
EntityFactory.CreateVolume("3", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("31", false, new List<MangaFile>()),
|
||||
}),
|
||||
}
|
||||
}
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("1").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("2").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("0").WithPages(1).Build())
|
||||
.Build())
|
||||
|
||||
.WithVolume(new VolumeBuilder("3")
|
||||
.WithChapter(new ChapterBuilder("31").WithPages(1).Build())
|
||||
.Build())
|
||||
.Build(),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -308,21 +278,16 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("0", false, new List<MangaFile>()),
|
||||
}),
|
||||
EntityFactory.CreateVolume("3", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("0", false, new List<MangaFile>()),
|
||||
}),
|
||||
}
|
||||
}
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("0").WithPages(1).Build())
|
||||
.Build())
|
||||
|
||||
.WithVolume(new VolumeBuilder("3")
|
||||
.WithChapter(new ChapterBuilder("0").WithPages(1).Build())
|
||||
.Build())
|
||||
.Build(),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -354,21 +319,15 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("Ano Orokamono ni mo Kyakkou wo! - Volume 1.epub", true, new List<MangaFile>()),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("Ano Orokamono ni mo Kyakkou wo! - Volume 2.epub", false, new List<MangaFile>()),
|
||||
}),
|
||||
}
|
||||
}
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("Ano Orokamono ni mo Kyakkou wo! - Volume 1.epub", "Ano Orokamono ni mo Kyakkou wo! - Volume 1.epub").WithIsSpecial(true).WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("Ano Orokamono ni mo Kyakkou wo! - Volume 2.epub", "Ano Orokamono ni mo Kyakkou wo! - Volume 2.epub").WithPages(1).Build())
|
||||
.Build())
|
||||
.Build(),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -407,25 +366,19 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Manga,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("0", false, new List<MangaFile>()),
|
||||
}),
|
||||
EntityFactory.CreateVolume("1.2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("0", false, new List<MangaFile>()),
|
||||
}),
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("0", false, new List<MangaFile>()),
|
||||
}),
|
||||
}
|
||||
}
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("0").WithPages(1).Build())
|
||||
.Build())
|
||||
|
||||
.WithVolume(new VolumeBuilder("1.2")
|
||||
.WithChapter(new ChapterBuilder("0").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithChapter(new ChapterBuilder("0").WithPages(1).Build())
|
||||
.Build())
|
||||
.Build(),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -462,17 +415,12 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Manga,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
}
|
||||
}
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithChapter(new ChapterBuilder("1").WithPages(1).Build())
|
||||
.Build())
|
||||
.Build(),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -516,17 +464,12 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Manga,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
}
|
||||
}
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithChapter(new ChapterBuilder("1").WithPages(1).Build())
|
||||
.Build())
|
||||
.Build(),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -587,17 +530,12 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Manga,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
}
|
||||
}
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithChapter(new ChapterBuilder("1").WithPages(1).Build())
|
||||
.Build())
|
||||
.Build(),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -639,17 +577,12 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Manga,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
}
|
||||
}
|
||||
new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithChapter(new ChapterBuilder("1").WithPages(1).Build())
|
||||
.Build())
|
||||
.Build(),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -678,14 +611,16 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
public async Task UpdateSeriesMetadata_ShouldCreateEmptyMetadata_IfDoesntExist()
|
||||
{
|
||||
await ResetDb();
|
||||
_context.Series.Add(new Series()
|
||||
var s = new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.Build();
|
||||
s.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library() {
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
}
|
||||
});
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
};
|
||||
|
||||
_context.Series.Add(s);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var success = await _seriesService.UpdateSeriesMetadata(new UpdateSeriesMetadataDto()
|
||||
|
|
@ -710,14 +645,16 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
public async Task UpdateSeriesMetadata_ShouldCreateNewTags_IfNoneExist()
|
||||
{
|
||||
await ResetDb();
|
||||
_context.Series.Add(new Series()
|
||||
var s = new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.Build();
|
||||
s.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library() {
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
}
|
||||
});
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
};
|
||||
|
||||
_context.Series.Add(s);
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var success = await _seriesService.UpdateSeriesMetadata(new UpdateSeriesMetadataDto()
|
||||
|
|
@ -752,16 +689,15 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
public async Task UpdateSeriesMetadata_ShouldRemoveExistingTags()
|
||||
{
|
||||
await ResetDb();
|
||||
var s = new Series()
|
||||
var s = new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadataBuilder().Build())
|
||||
.Build();
|
||||
s.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
},
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>())
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
};
|
||||
|
||||
var g = DbFactory.Genre("Existing Genre");
|
||||
s.Metadata.Genres = new List<Genre>() {g};
|
||||
_context.Series.Add(s);
|
||||
|
|
@ -791,16 +727,15 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
public async Task UpdateSeriesMetadata_ShouldAddNewPerson_NoExistingPeople()
|
||||
{
|
||||
await ResetDb();
|
||||
var s = new Series()
|
||||
var s = new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadataBuilder().Build())
|
||||
.Build();
|
||||
s.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
},
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>())
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
};
|
||||
|
||||
var g = DbFactory.Person("Existing Person", PersonRole.Publisher);
|
||||
_context.Series.Add(s);
|
||||
|
||||
|
|
@ -829,15 +764,13 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
public async Task UpdateSeriesMetadata_ShouldAddNewPerson_ExistingPeople()
|
||||
{
|
||||
await ResetDb();
|
||||
var s = new Series()
|
||||
var s = new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadataBuilder().Build())
|
||||
.Build();
|
||||
s.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
},
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>())
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
};
|
||||
var g = DbFactory.Person("Existing Person", PersonRole.Publisher);
|
||||
s.Metadata.People = new List<Person>() {DbFactory.Person("Existing Writer", PersonRole.Writer),
|
||||
|
|
@ -871,15 +804,13 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
public async Task UpdateSeriesMetadata_ShouldRemoveExistingPerson()
|
||||
{
|
||||
await ResetDb();
|
||||
var s = new Series()
|
||||
var s = new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadataBuilder().Build())
|
||||
.Build();
|
||||
s.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
},
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>())
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
};
|
||||
var g = DbFactory.Person("Existing Person", PersonRole.Publisher);
|
||||
_context.Series.Add(s);
|
||||
|
|
@ -908,15 +839,13 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
public async Task UpdateSeriesMetadata_ShouldLockIfTold()
|
||||
{
|
||||
await ResetDb();
|
||||
var s = new Series()
|
||||
var s = new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadataBuilder().Build())
|
||||
.Build();
|
||||
s.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
},
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>())
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
};
|
||||
var g = DbFactory.Genre("Existing Genre");
|
||||
s.Metadata.Genres = new List<Genre>() {g};
|
||||
|
|
@ -949,15 +878,13 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
public async Task UpdateSeriesMetadata_ShouldNotUpdateReleaseYear_IfLessThan1000()
|
||||
{
|
||||
await ResetDb();
|
||||
var s = new Series()
|
||||
var s = new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadataBuilder().Build())
|
||||
.Build();
|
||||
s.Library = new Library()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
},
|
||||
Metadata = DbFactory.SeriesMetadata(new List<CollectionTag>())
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Book,
|
||||
};
|
||||
_context.Series.Add(s);
|
||||
await _context.SaveChangesAsync();
|
||||
|
|
@ -986,43 +913,37 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
|
||||
private static Series CreateSeriesMock()
|
||||
{
|
||||
var files = new List<MangaFile>()
|
||||
var file = EntityFactory.CreateMangaFile("Test.cbz", MangaFormat.Archive, 1);
|
||||
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithMetadata(new SeriesMetadata())
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("95").WithPages(1).WithFile(file).Build())
|
||||
.WithChapter(new ChapterBuilder("96").WithPages(1).WithFile(file).Build())
|
||||
.WithChapter(new ChapterBuilder("A Special Case").WithIsSpecial(true).WithFile(file).WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithChapter(new ChapterBuilder("1").WithPages(1).WithFile(file).Build())
|
||||
.WithChapter(new ChapterBuilder("2").WithPages(1).WithFile(file).Build())
|
||||
.Build())
|
||||
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("21").WithPages(1).WithFile(file).Build())
|
||||
.WithChapter(new ChapterBuilder("22").WithPages(1).WithFile(file).Build())
|
||||
.Build())
|
||||
|
||||
.WithVolume(new VolumeBuilder("3")
|
||||
.WithChapter(new ChapterBuilder("31").WithPages(1).WithFile(file).Build())
|
||||
.WithChapter(new ChapterBuilder("32").WithPages(1).WithFile(file).Build())
|
||||
.Build())
|
||||
.Build();
|
||||
series.Library = new Library()
|
||||
{
|
||||
EntityFactory.CreateMangaFile("Test.cbz", MangaFormat.Archive, 1)
|
||||
};
|
||||
return new Series()
|
||||
{
|
||||
Name = "Test",
|
||||
Library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
},
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("95", false, files, 1),
|
||||
EntityFactory.CreateChapter("96", false, files, 1),
|
||||
EntityFactory.CreateChapter("A Special Case", true, files, 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", false, files, 1),
|
||||
EntityFactory.CreateChapter("2", false, files, 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("21", false, files, 1),
|
||||
EntityFactory.CreateChapter("22", false, files, 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("3", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("31", false, files, 1),
|
||||
EntityFactory.CreateChapter("32", false, files, 1),
|
||||
}),
|
||||
}
|
||||
Name = "Test LIb",
|
||||
Type = LibraryType.Manga,
|
||||
};
|
||||
|
||||
return series;
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
|
@ -1082,21 +1003,9 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series Prequels",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series Sequels",
|
||||
Volumes = new List<Volume>(){}
|
||||
}
|
||||
new SeriesBuilder("Test Series").Build(),
|
||||
new SeriesBuilder("Test Series Prequels").Build(),
|
||||
new SeriesBuilder("Test Series Sequels").Build(),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1129,21 +1038,9 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series Prequels",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series Sequels",
|
||||
Volumes = new List<Volume>(){}
|
||||
}
|
||||
DbFactory.Series("Test Series"),
|
||||
DbFactory.Series("Test Series Prequels"),
|
||||
DbFactory.Series("Test Series Sequels"),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1183,16 +1080,8 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Series A",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Series B",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
DbFactory.Series("Series A"),
|
||||
DbFactory.Series("Series B"),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1236,16 +1125,8 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Series A",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Series B",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
DbFactory.Series("Series A"),
|
||||
DbFactory.Series("Series B"),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1289,16 +1170,8 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series Prequels",
|
||||
Volumes = new List<Volume>(){}
|
||||
}
|
||||
DbFactory.Series("Test Series"),
|
||||
DbFactory.Series("Test Series Prequels"),
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1342,31 +1215,11 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series Editions",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series Prequels",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series Sequels",
|
||||
Volumes = new List<Volume>(){}
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series Adaption",
|
||||
Volumes = new List<Volume>(){}
|
||||
}
|
||||
DbFactory.Series("Test Series"),
|
||||
DbFactory.Series("Test Series Editions"),
|
||||
DbFactory.Series("Test Series Prequels"),
|
||||
DbFactory.Series("Test Series Sequels"),
|
||||
DbFactory.Series("Test Series Adaption"),
|
||||
}
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
|
|
@ -1403,21 +1256,9 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series",
|
||||
Volumes = new List<Volume>() { }
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series Prequels",
|
||||
Volumes = new List<Volume>() { }
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series Sequels",
|
||||
Volumes = new List<Volume>() { }
|
||||
}
|
||||
DbFactory.Series("Test Series"),
|
||||
DbFactory.Series("Test Series Prequels"),
|
||||
DbFactory.Series("Test Series Sequels"),
|
||||
}
|
||||
};
|
||||
_context.Library.Add(lib);
|
||||
|
|
@ -1463,40 +1304,17 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
new Volume()
|
||||
new SeriesBuilder("Test Series")
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("1").WithFile(new MangaFile()
|
||||
{
|
||||
Chapters = new List<Chapter>()
|
||||
{
|
||||
new Chapter()
|
||||
{
|
||||
Files = new List<MangaFile>()
|
||||
{
|
||||
new MangaFile()
|
||||
{
|
||||
Pages = 1,
|
||||
FilePath = "fake file"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series Prequels",
|
||||
Volumes = new List<Volume>() { }
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series Sequels",
|
||||
Volumes = new List<Volume>() { }
|
||||
}
|
||||
Pages = 1,
|
||||
FilePath = "fake file"
|
||||
}).Build())
|
||||
.Build())
|
||||
.Build(),
|
||||
new SeriesBuilder("Test Series Prequels").Build(),
|
||||
new SeriesBuilder("Test Series Sequels").Build(),
|
||||
}
|
||||
};
|
||||
_context.Library.Add(lib1);
|
||||
|
|
@ -1513,21 +1331,9 @@ public class SeriesServiceTests : AbstractDbTest
|
|||
Type = LibraryType.Book,
|
||||
Series = new List<Series>()
|
||||
{
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series 2",
|
||||
Volumes = new List<Volume>() { }
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series Prequels 2",
|
||||
Volumes = new List<Volume>() { }
|
||||
},
|
||||
new Series()
|
||||
{
|
||||
Name = "Test Series Sequels 2",
|
||||
Volumes = new List<Volume>() { }
|
||||
}
|
||||
DbFactory.Series("Test Series 2"),
|
||||
DbFactory.Series("Test Series Prequels 2"),
|
||||
DbFactory.Series("Test Series Prequels 2"),
|
||||
}
|
||||
};
|
||||
_context.Library.Add(lib2);
|
||||
|
|
|
|||
|
|
@ -1,138 +1,71 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.Data;
|
||||
using API.Entities;
|
||||
using API.Entities.Enums;
|
||||
using API.Entities.Enums.Theme;
|
||||
using API.Entities.Enums.UserPreferences;
|
||||
using API.Helpers;
|
||||
using API.Extensions;
|
||||
using API.Services;
|
||||
using API.Services.Tasks;
|
||||
using API.SignalR;
|
||||
using AutoMapper;
|
||||
using Kavita.Common;
|
||||
using Microsoft.AspNetCore.SignalR;
|
||||
using Microsoft.Data.Sqlite;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Microsoft.EntityFrameworkCore.Infrastructure;
|
||||
using Microsoft.Extensions.Logging;
|
||||
using NSubstitute;
|
||||
using Xunit;
|
||||
using Xunit.Abstractions;
|
||||
|
||||
namespace API.Tests.Services;
|
||||
|
||||
public class SiteThemeServiceTests
|
||||
|
||||
public abstract class SiteThemeServiceTest : AbstractDbTest
|
||||
{
|
||||
private readonly ILogger<ThemeService> _logger = Substitute.For<ILogger<ThemeService>>();
|
||||
private readonly ITestOutputHelper _testOutputHelper;
|
||||
private readonly IEventHub _messageHub = Substitute.For<IEventHub>();
|
||||
|
||||
private readonly DbConnection _connection;
|
||||
private readonly DataContext _context;
|
||||
private readonly IUnitOfWork _unitOfWork;
|
||||
|
||||
private const string CacheDirectory = "C:/kavita/config/cache/";
|
||||
private const string CoverImageDirectory = "C:/kavita/config/covers/";
|
||||
private const string BackupDirectory = "C:/kavita/config/backups/";
|
||||
private const string BookmarkDirectory = "C:/kavita/config/bookmarks/";
|
||||
private const string SiteThemeDirectory = "C:/kavita/config/themes/";
|
||||
|
||||
public SiteThemeServiceTests()
|
||||
protected SiteThemeServiceTest(ITestOutputHelper testOutputHelper) : base()
|
||||
{
|
||||
var contextOptions = new DbContextOptionsBuilder()
|
||||
.UseSqlite(CreateInMemoryDatabase())
|
||||
.Options;
|
||||
_connection = RelationalOptionsExtension.Extract(contextOptions).Connection;
|
||||
|
||||
_context = new DataContext(contextOptions);
|
||||
Task.Run(SeedDb).GetAwaiter().GetResult();
|
||||
|
||||
var config = new MapperConfiguration(cfg => cfg.AddProfile<AutoMapperProfiles>());
|
||||
var mapper = config.CreateMapper();
|
||||
_unitOfWork = new UnitOfWork(_context, mapper, null);
|
||||
_testOutputHelper = testOutputHelper;
|
||||
}
|
||||
|
||||
#region Setup
|
||||
|
||||
private static DbConnection CreateInMemoryDatabase()
|
||||
{
|
||||
var connection = new SqliteConnection("Filename=:memory:");
|
||||
|
||||
connection.Open();
|
||||
|
||||
return connection;
|
||||
}
|
||||
|
||||
private async Task<bool> SeedDb()
|
||||
{
|
||||
await _context.Database.MigrateAsync();
|
||||
var filesystem = CreateFileSystem();
|
||||
|
||||
await Seed.SeedSettings(_context, new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), filesystem));
|
||||
|
||||
var setting = await _context.ServerSetting.Where(s => s.Key == ServerSettingKey.CacheDirectory).SingleAsync();
|
||||
setting.Value = CacheDirectory;
|
||||
|
||||
setting = await _context.ServerSetting.Where(s => s.Key == ServerSettingKey.BackupDirectory).SingleAsync();
|
||||
setting.Value = BackupDirectory;
|
||||
|
||||
setting = await _context.ServerSetting.Where(s => s.Key == ServerSettingKey.BookmarkDirectory).SingleAsync();
|
||||
setting.Value = BookmarkDirectory;
|
||||
|
||||
_context.ServerSetting.Update(setting);
|
||||
|
||||
_context.AppUser.Add(new AppUser()
|
||||
{
|
||||
UserName = "Joe",
|
||||
UserPreferences = new AppUserPreferences
|
||||
{
|
||||
Theme = Seed.DefaultThemes[0]
|
||||
}
|
||||
});
|
||||
|
||||
_context.Library.Add(new Library()
|
||||
{
|
||||
Name = "Manga",
|
||||
Folders = new List<FolderPath>()
|
||||
{
|
||||
new FolderPath()
|
||||
{
|
||||
Path = "C:/data/"
|
||||
}
|
||||
}
|
||||
});
|
||||
return await _context.SaveChangesAsync() > 0;
|
||||
}
|
||||
|
||||
private static MockFileSystem CreateFileSystem()
|
||||
{
|
||||
var fileSystem = new MockFileSystem();
|
||||
fileSystem.Directory.SetCurrentDirectory("C:/kavita/");
|
||||
fileSystem.AddDirectory("C:/kavita/config/");
|
||||
fileSystem.AddDirectory(CacheDirectory);
|
||||
fileSystem.AddDirectory(CoverImageDirectory);
|
||||
fileSystem.AddDirectory(BackupDirectory);
|
||||
fileSystem.AddDirectory(BookmarkDirectory);
|
||||
fileSystem.AddDirectory(SiteThemeDirectory);
|
||||
fileSystem.AddDirectory("C:/data/");
|
||||
|
||||
return fileSystem;
|
||||
}
|
||||
|
||||
private async Task ResetDb()
|
||||
protected override async Task ResetDb()
|
||||
{
|
||||
_context.SiteTheme.RemoveRange(_context.SiteTheme);
|
||||
await _context.SaveChangesAsync();
|
||||
// Recreate defaults
|
||||
await Seed.SeedThemes(_context);
|
||||
}
|
||||
|
||||
#endregion
|
||||
[Fact]
|
||||
public async Task UpdateDefault_ShouldThrowOnInvalidId()
|
||||
{
|
||||
await ResetDb();
|
||||
_testOutputHelper.WriteLine($"[UpdateDefault_ShouldThrowOnInvalidId] All Themes: {(await _unitOfWork.SiteThemeRepository.GetThemes()).Count(t => t.IsDefault)}");
|
||||
var filesystem = CreateFileSystem();
|
||||
filesystem.AddFile($"{SiteThemeDirectory}custom.css", new MockFileData("123"));
|
||||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), filesystem);
|
||||
var siteThemeService = new ThemeService(ds, _unitOfWork, _messageHub);
|
||||
|
||||
_context.SiteTheme.Add(new SiteTheme()
|
||||
{
|
||||
Name = "Custom",
|
||||
NormalizedName = "Custom".ToNormalized(),
|
||||
Provider = ThemeProvider.User,
|
||||
FileName = "custom.css",
|
||||
IsDefault = false
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
var ex = await Assert.ThrowsAsync<KavitaException>(async () => await siteThemeService.UpdateDefault(10));
|
||||
Assert.Equal("Theme file missing or invalid", ex.Message);
|
||||
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task Scan_ShouldFindCustomFile()
|
||||
{
|
||||
await ResetDb();
|
||||
_testOutputHelper.WriteLine($"[Scan_ShouldOnlyInsertOnceOnSecondScan] All Themes: {(await _unitOfWork.SiteThemeRepository.GetThemes()).Count(t => t.IsDefault)}");
|
||||
var filesystem = CreateFileSystem();
|
||||
filesystem.AddFile($"{SiteThemeDirectory}custom.css", new MockFileData(""));
|
||||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), filesystem);
|
||||
|
|
@ -146,6 +79,8 @@ public class SiteThemeServiceTests
|
|||
public async Task Scan_ShouldOnlyInsertOnceOnSecondScan()
|
||||
{
|
||||
await ResetDb();
|
||||
_testOutputHelper.WriteLine(
|
||||
$"[Scan_ShouldOnlyInsertOnceOnSecondScan] All Themes: {(await _unitOfWork.SiteThemeRepository.GetThemes()).Count(t => t.IsDefault)}");
|
||||
var filesystem = CreateFileSystem();
|
||||
filesystem.AddFile($"{SiteThemeDirectory}custom.css", new MockFileData(""));
|
||||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), filesystem);
|
||||
|
|
@ -157,7 +92,8 @@ public class SiteThemeServiceTests
|
|||
await siteThemeService.Scan();
|
||||
|
||||
var customThemes = (await _unitOfWork.SiteThemeRepository.GetThemeDtos()).Where(t =>
|
||||
API.Services.Tasks.Scanner.Parser.Parser.Normalize(t.Name).Equals(API.Services.Tasks.Scanner.Parser.Parser.Normalize("custom")));
|
||||
t.Name.ToNormalized().Equals("custom".ToNormalized()));
|
||||
|
||||
Assert.Single(customThemes);
|
||||
}
|
||||
|
||||
|
|
@ -165,6 +101,7 @@ public class SiteThemeServiceTests
|
|||
public async Task Scan_ShouldDeleteWhenFileDoesntExistOnSecondScan()
|
||||
{
|
||||
await ResetDb();
|
||||
_testOutputHelper.WriteLine($"[Scan_ShouldDeleteWhenFileDoesntExistOnSecondScan] All Themes: {(await _unitOfWork.SiteThemeRepository.GetThemes()).Count(t => t.IsDefault)}");
|
||||
var filesystem = CreateFileSystem();
|
||||
filesystem.AddFile($"{SiteThemeDirectory}custom.css", new MockFileData(""));
|
||||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), filesystem);
|
||||
|
|
@ -176,16 +113,17 @@ public class SiteThemeServiceTests
|
|||
filesystem.RemoveFile($"{SiteThemeDirectory}custom.css");
|
||||
await siteThemeService.Scan();
|
||||
|
||||
var customThemes = (await _unitOfWork.SiteThemeRepository.GetThemeDtos()).Where(t =>
|
||||
API.Services.Tasks.Scanner.Parser.Parser.Normalize(t.Name).Equals(API.Services.Tasks.Scanner.Parser.Parser.Normalize("custom")));
|
||||
var themes = (await _unitOfWork.SiteThemeRepository.GetThemeDtos());
|
||||
|
||||
Assert.Empty(customThemes);
|
||||
Assert.Equal(0, themes.Count(t =>
|
||||
t.Name.ToNormalized().Equals("custom".ToNormalized())));
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task GetContent_ShouldReturnContent()
|
||||
{
|
||||
await ResetDb();
|
||||
_testOutputHelper.WriteLine($"[GetContent_ShouldReturnContent] All Themes: {(await _unitOfWork.SiteThemeRepository.GetThemes()).Count(t => t.IsDefault)}");
|
||||
var filesystem = CreateFileSystem();
|
||||
filesystem.AddFile($"{SiteThemeDirectory}custom.css", new MockFileData("123"));
|
||||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), filesystem);
|
||||
|
|
@ -194,7 +132,7 @@ public class SiteThemeServiceTests
|
|||
_context.SiteTheme.Add(new SiteTheme()
|
||||
{
|
||||
Name = "Custom",
|
||||
NormalizedName = API.Services.Tasks.Scanner.Parser.Parser.Normalize("Custom"),
|
||||
NormalizedName = "Custom".ToNormalized(),
|
||||
Provider = ThemeProvider.User,
|
||||
FileName = "custom.css",
|
||||
IsDefault = false
|
||||
|
|
@ -211,6 +149,7 @@ public class SiteThemeServiceTests
|
|||
public async Task UpdateDefault_ShouldHaveOneDefault()
|
||||
{
|
||||
await ResetDb();
|
||||
_testOutputHelper.WriteLine($"[UpdateDefault_ShouldHaveOneDefault] All Themes: {(await _unitOfWork.SiteThemeRepository.GetThemes()).Count(t => t.IsDefault)}");
|
||||
var filesystem = CreateFileSystem();
|
||||
filesystem.AddFile($"{SiteThemeDirectory}custom.css", new MockFileData("123"));
|
||||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), filesystem);
|
||||
|
|
@ -219,7 +158,7 @@ public class SiteThemeServiceTests
|
|||
_context.SiteTheme.Add(new SiteTheme()
|
||||
{
|
||||
Name = "Custom",
|
||||
NormalizedName = API.Services.Tasks.Scanner.Parser.Parser.Normalize("Custom"),
|
||||
NormalizedName = "Custom".ToNormalized(),
|
||||
Provider = ThemeProvider.User,
|
||||
FileName = "custom.css",
|
||||
IsDefault = false
|
||||
|
|
@ -228,6 +167,7 @@ public class SiteThemeServiceTests
|
|||
|
||||
var customTheme = (await _unitOfWork.SiteThemeRepository.GetThemeDtoByName("Custom"));
|
||||
|
||||
Assert.NotNull(customTheme);
|
||||
await siteThemeService.UpdateDefault(customTheme.Id);
|
||||
|
||||
|
||||
|
|
@ -235,31 +175,5 @@ public class SiteThemeServiceTests
|
|||
Assert.Equal(customTheme.Id, (await _unitOfWork.SiteThemeRepository.GetDefaultTheme()).Id);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task UpdateDefault_ShouldThrowOnInvalidId()
|
||||
{
|
||||
await ResetDb();
|
||||
var filesystem = CreateFileSystem();
|
||||
filesystem.AddFile($"{SiteThemeDirectory}custom.css", new MockFileData("123"));
|
||||
var ds = new DirectoryService(Substitute.For<ILogger<DirectoryService>>(), filesystem);
|
||||
var siteThemeService = new ThemeService(ds, _unitOfWork, _messageHub);
|
||||
|
||||
_context.SiteTheme.Add(new SiteTheme()
|
||||
{
|
||||
Name = "Custom",
|
||||
NormalizedName = API.Services.Tasks.Scanner.Parser.Parser.Normalize("Custom"),
|
||||
Provider = ThemeProvider.User,
|
||||
FileName = "custom.css",
|
||||
IsDefault = false
|
||||
});
|
||||
await _context.SaveChangesAsync();
|
||||
|
||||
|
||||
|
||||
var ex = await Assert.ThrowsAsync<KavitaException>(async () => await siteThemeService.UpdateDefault(10));
|
||||
Assert.Equal("Theme file missing or invalid", ex.Message);
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
namespace API.Tests.Services;
|
||||
using API.Extensions;
|
||||
using API.Tests.Helpers.Builders;
|
||||
|
||||
namespace API.Tests.Services;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
|
|
@ -111,33 +114,25 @@ public class TachiyomiServiceTests
|
|||
{
|
||||
await ResetDb();
|
||||
|
||||
var series = new Series
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("95", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("96", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", true, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("3", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("4", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("3", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("31", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("32", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
},
|
||||
Pages = 7
|
||||
};
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("95").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("96").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithChapter(new ChapterBuilder("1").WithIsSpecial(true).WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("3").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("4").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("3")
|
||||
.WithChapter(new ChapterBuilder("31").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("32").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithPages(7)
|
||||
.Build();
|
||||
|
||||
var library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
|
|
@ -169,33 +164,25 @@ public class TachiyomiServiceTests
|
|||
{
|
||||
await ResetDb();
|
||||
|
||||
var series = new Series
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("95", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("96", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", true, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("3", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("4", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("3", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("31", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("32", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
},
|
||||
Pages = 7
|
||||
};
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("95").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("96").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithChapter(new ChapterBuilder("1").WithIsSpecial(true).WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("3").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("4").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("3")
|
||||
.WithChapter(new ChapterBuilder("31").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("32").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithPages(7)
|
||||
.Build();
|
||||
|
||||
var library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
|
|
@ -233,33 +220,25 @@ public class TachiyomiServiceTests
|
|||
{
|
||||
await ResetDb();
|
||||
|
||||
var series = new Series
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("95", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("96", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("21", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("23", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("3", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("31", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("32", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
},
|
||||
Pages = 7
|
||||
};
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("95").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("96").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithChapter(new ChapterBuilder("1").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("21").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("22").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("3")
|
||||
.WithChapter(new ChapterBuilder("31").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("32").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithPages(7)
|
||||
.Build();
|
||||
|
||||
var library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
|
|
@ -296,33 +275,25 @@ public class TachiyomiServiceTests
|
|||
{
|
||||
await ResetDb();
|
||||
|
||||
var series = new Series
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("95", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("96", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", true, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("21", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("23", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("3", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("31", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("32", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
},
|
||||
Pages = 7
|
||||
};
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("95").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("96").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithChapter(new ChapterBuilder("1").WithIsSpecial(true).WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("21").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("22").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("3")
|
||||
.WithChapter(new ChapterBuilder("31").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("32").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithPages(7)
|
||||
.Build();
|
||||
|
||||
var library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
|
|
@ -360,26 +331,19 @@ public class TachiyomiServiceTests
|
|||
{
|
||||
await ResetDb();
|
||||
|
||||
var series = new Series
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("0", false, new List<MangaFile>(), 199),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("0", false, new List<MangaFile>(), 192),
|
||||
}),
|
||||
EntityFactory.CreateVolume("3", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("0", false, new List<MangaFile>(), 255),
|
||||
}),
|
||||
},
|
||||
Pages = 646
|
||||
};
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithChapter(new ChapterBuilder("0").WithPages(199).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("0").WithPages(192).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("3")
|
||||
.WithChapter(new ChapterBuilder("0").WithPages(255).Build())
|
||||
.Build())
|
||||
.WithPages(646)
|
||||
.Build();
|
||||
|
||||
var library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
|
|
@ -418,31 +382,23 @@ public class TachiyomiServiceTests
|
|||
{
|
||||
await ResetDb();
|
||||
|
||||
var series = new Series
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("95", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("96", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("1997", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2002", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("2", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2005", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("3", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
},
|
||||
Pages = 7
|
||||
};
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("95").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("96").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("1997")
|
||||
.WithChapter(new ChapterBuilder("1").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2002")
|
||||
.WithChapter(new ChapterBuilder("2").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2005")
|
||||
.WithChapter(new ChapterBuilder("3").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithPages(7)
|
||||
.Build();
|
||||
|
||||
var library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
|
|
@ -485,33 +441,25 @@ public class TachiyomiServiceTests
|
|||
{
|
||||
await ResetDb();
|
||||
|
||||
var series = new Series
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("95", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("96", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", true, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("3", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("4", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("3", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("31", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("32", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
},
|
||||
Pages = 7
|
||||
};
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("95").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("96").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithChapter(new ChapterBuilder("1").WithIsSpecial(true).WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("3").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("4").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("3")
|
||||
.WithChapter(new ChapterBuilder("31").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("32").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithPages(7)
|
||||
.Build();
|
||||
|
||||
var library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
|
|
@ -542,33 +490,25 @@ public class TachiyomiServiceTests
|
|||
{
|
||||
await ResetDb();
|
||||
|
||||
var series = new Series
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("95", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("96", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", true, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("3", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("4", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("3", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("31", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("32", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
},
|
||||
Pages = 7
|
||||
};
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("95").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("96").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithChapter(new ChapterBuilder("1").WithIsSpecial(true).WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("3").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("4").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("3")
|
||||
.WithChapter(new ChapterBuilder("31").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("32").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithPages(7)
|
||||
.Build();
|
||||
|
||||
var library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
|
|
@ -606,33 +546,25 @@ public class TachiyomiServiceTests
|
|||
{
|
||||
await ResetDb();
|
||||
|
||||
var series = new Series
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("95", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("96", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("21", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("23", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("3", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("31", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("32", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
},
|
||||
Pages = 7
|
||||
};
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("95").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("96").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithChapter(new ChapterBuilder("1").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("21").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("23").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("3")
|
||||
.WithChapter(new ChapterBuilder("31").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("32").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithPages(7)
|
||||
.Build();
|
||||
|
||||
var library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
|
|
@ -668,34 +600,25 @@ public class TachiyomiServiceTests
|
|||
public async Task MarkChaptersUntilAsRead_ShouldReturnEncodedVolume_Progress()
|
||||
{
|
||||
await ResetDb();
|
||||
var series = new SeriesBuilder("Test")
|
||||
.WithVolume(new VolumeBuilder("0")
|
||||
.WithChapter(new ChapterBuilder("95").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("96").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("1")
|
||||
.WithChapter(new ChapterBuilder("1").WithIsSpecial(true).WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("2")
|
||||
.WithChapter(new ChapterBuilder("21").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("23").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithVolume(new VolumeBuilder("3")
|
||||
.WithChapter(new ChapterBuilder("31").WithPages(1).Build())
|
||||
.WithChapter(new ChapterBuilder("32").WithPages(1).Build())
|
||||
.Build())
|
||||
.WithPages(7)
|
||||
.Build();
|
||||
|
||||
var series = new Series
|
||||
{
|
||||
Name = "Test",
|
||||
Volumes = new List<Volume>()
|
||||
{
|
||||
EntityFactory.CreateVolume("0", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("95", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("96", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("1", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("1", true, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("2", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("21", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("23", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
EntityFactory.CreateVolume("3", new List<Chapter>()
|
||||
{
|
||||
EntityFactory.CreateChapter("31", false, new List<MangaFile>(), 1),
|
||||
EntityFactory.CreateChapter("32", false, new List<MangaFile>(), 1),
|
||||
}),
|
||||
},
|
||||
Pages = 7
|
||||
};
|
||||
var library = new Library()
|
||||
{
|
||||
Name = "Test LIb",
|
||||
|
|
|
|||
Binary file not shown.
|
Before Width: | Height: | Size: 142 KiB After Width: | Height: | Size: 143 KiB |
|
|
@ -1,7 +1,5 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.IO.Abstractions.TestingHelpers;
|
||||
using System.Linq;
|
||||
using System.Threading.Tasks;
|
||||
using API.Entities;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue