mirror of
https://github.com/Kareadita/Kavita.git
synced 2026-06-04 13:55:22 -04:00
Basic Metadata Polish (#3548)
This commit is contained in:
@@ -26,6 +26,7 @@ public abstract class AbstractDbTest : IDisposable
|
||||
protected readonly DbConnection _connection;
|
||||
protected readonly DataContext _context;
|
||||
protected readonly IUnitOfWork _unitOfWork;
|
||||
protected readonly IMapper _mapper;
|
||||
|
||||
|
||||
protected const string CacheDirectory = "C:/kavita/config/cache/";
|
||||
@@ -42,6 +43,7 @@ public abstract class AbstractDbTest : IDisposable
|
||||
{
|
||||
var contextOptions = new DbContextOptionsBuilder<DataContext>()
|
||||
.UseSqlite(CreateInMemoryDatabase())
|
||||
.EnableSensitiveDataLogging()
|
||||
.Options;
|
||||
|
||||
_connection = RelationalOptionsExtension.Extract(contextOptions).Connection;
|
||||
@@ -53,10 +55,10 @@ public abstract class AbstractDbTest : IDisposable
|
||||
Task.Run(SeedDb).GetAwaiter().GetResult();
|
||||
|
||||
var config = new MapperConfiguration(cfg => cfg.AddProfile<AutoMapperProfiles>());
|
||||
var mapper = config.CreateMapper();
|
||||
_mapper = config.CreateMapper();
|
||||
|
||||
GlobalConfiguration.Configuration.UseInMemoryStorage();
|
||||
_unitOfWork = new UnitOfWork(_context, mapper, null);
|
||||
_unitOfWork = new UnitOfWork(_context, _mapper, null);
|
||||
}
|
||||
|
||||
private static DbConnection CreateInMemoryDatabase()
|
||||
@@ -92,6 +94,7 @@ public abstract class AbstractDbTest : IDisposable
|
||||
|
||||
|
||||
_context.Library.Add(new LibraryBuilder("Manga")
|
||||
.WithAllowMetadataMatching(true)
|
||||
.WithFolderPath(new FolderPathBuilder(DataDirectory).Build())
|
||||
.Build());
|
||||
|
||||
|
||||
@@ -932,11 +932,11 @@ public class SeriesFilterTests : AbstractDbTest
|
||||
|
||||
var seriesService = new SeriesService(_unitOfWork, Substitute.For<IEventHub>(),
|
||||
Substitute.For<ITaskScheduler>(), Substitute.For<ILogger<SeriesService>>(),
|
||||
Substitute.For<IScrobblingService>(), Substitute.For<ILocalizationService>()
|
||||
, Substitute.For<IImageService>());
|
||||
Substitute.For<IScrobblingService>(), Substitute.For<ILocalizationService>());
|
||||
|
||||
// Select 0 Rating
|
||||
var zeroRating = await _unitOfWork.SeriesRepository.GetSeriesByIdAsync(2);
|
||||
Assert.NotNull(zeroRating);
|
||||
|
||||
Assert.True(await seriesService.UpdateRating(user, new UpdateSeriesRatingDto()
|
||||
{
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
using System;
|
||||
using API.Helpers;
|
||||
using Xunit;
|
||||
|
||||
namespace API.Tests.Helpers;
|
||||
|
||||
public class StringHelperTests
|
||||
{
|
||||
[Theory]
|
||||
[InlineData(
|
||||
"<p>A Perfect Marriage Becomes a Perfect Affair!<br /> <br><br><br /> Every woman wishes for that happily ever after, but when time flies by and you've become a neglected housewife, what's a woman to do?</p>",
|
||||
"<p>A Perfect Marriage Becomes a Perfect Affair!<br /> Every woman wishes for that happily ever after, but when time flies by and you've become a neglected housewife, what's a woman to do?</p>"
|
||||
)]
|
||||
public void Test(string input, string expected)
|
||||
{
|
||||
Assert.Equal(expected, StringHelper.SquashBreaklines(input));
|
||||
}
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -17,7 +17,7 @@ namespace API.Tests.Services;
|
||||
|
||||
public class ProcessSeriesTests
|
||||
{
|
||||
|
||||
// TODO: Implement
|
||||
|
||||
#region UpdateSeriesMetadata
|
||||
|
||||
|
||||
@@ -56,7 +56,7 @@ public class SeriesServiceTests : AbstractDbTest
|
||||
|
||||
_seriesService = new SeriesService(_unitOfWork, Substitute.For<IEventHub>(),
|
||||
Substitute.For<ITaskScheduler>(), Substitute.For<ILogger<SeriesService>>(),
|
||||
Substitute.For<IScrobblingService>(), locService, Substitute.For<IImageService>());
|
||||
Substitute.For<IScrobblingService>(), locService);
|
||||
}
|
||||
#region Setup
|
||||
|
||||
|
||||
Reference in New Issue
Block a user