You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
64 lines
1.8 KiB
64 lines
1.8 KiB
1 year ago
|
using System.Diagnostics.CodeAnalysis;
|
||
|
using System.IO.Abstractions;
|
||
1 year ago
|
using Recyclarr.Json.Loading;
|
||
1 year ago
|
|
||
1 year ago
|
namespace Recyclarr.IntegrationTests;
|
||
1 year ago
|
|
||
|
[TestFixture]
|
||
1 year ago
|
public class BulkJsonLoaderIntegrationTest : IntegrationTestFixture
|
||
1 year ago
|
{
|
||
|
[SuppressMessage("ReSharper", "NotAccessedPositionalProperty.Local")]
|
||
1 year ago
|
private sealed record TestGuideObject(string TrashId, int TrashScore, string Name);
|
||
|
|
||
|
[SuppressMessage("ReSharper", "NotAccessedPositionalProperty.Local")]
|
||
|
private sealed record TestServiceObject(int Id, string Name, bool IncludeCustomFormatWhenRenaming);
|
||
1 year ago
|
|
||
|
[Test]
|
||
|
public void Guide_deserialize_works()
|
||
|
{
|
||
|
var sut = Resolve<GuideJsonLoader>();
|
||
|
|
||
|
const string jsonData =
|
||
|
"""
|
||
|
{
|
||
|
"trash_id": "90cedc1fea7ea5d11298bebd3d1d3223",
|
||
|
"trash_score": "-10000",
|
||
|
"name": "TheName"
|
||
|
}
|
||
|
""";
|
||
|
|
||
|
Fs.AddFile(Fs.CurrentDirectory().File("file.json"), new MockFileData(jsonData));
|
||
|
|
||
1 year ago
|
var result = sut.LoadAllFilesAtPaths<TestGuideObject>(new[] {Fs.CurrentDirectory()});
|
||
1 year ago
|
|
||
|
result.Should().BeEquivalentTo(new[]
|
||
|
{
|
||
1 year ago
|
new TestGuideObject("90cedc1fea7ea5d11298bebd3d1d3223", -10000, "TheName")
|
||
1 year ago
|
});
|
||
|
}
|
||
|
|
||
|
[Test]
|
||
|
public void Service_deserialize_works()
|
||
|
{
|
||
|
var sut = Resolve<ServiceJsonLoader>();
|
||
|
|
||
|
const string jsonData =
|
||
|
"""
|
||
|
{
|
||
|
"id": 22,
|
||
|
"name": "FUNi",
|
||
|
"includeCustomFormatWhenRenaming": true
|
||
|
}
|
||
|
""";
|
||
|
|
||
|
Fs.AddFile(Fs.CurrentDirectory().File("file.json"), new MockFileData(jsonData));
|
||
|
|
||
1 year ago
|
var result = sut.LoadAllFilesAtPaths<TestServiceObject>(new[] {Fs.CurrentDirectory()});
|
||
1 year ago
|
|
||
|
result.Should().BeEquivalentTo(new[]
|
||
|
{
|
||
1 year ago
|
new TestServiceObject(22, "FUNi", true)
|
||
1 year ago
|
});
|
||
|
}
|
||
|
}
|