Updated scanner tests to work with user english locale pages.

This commit is contained in:
2025-10-17 19:47:15 -04:00
parent 278b6df650
commit dbe249194a
9 changed files with 470 additions and 63 deletions

View File

@@ -5,7 +5,7 @@ using JSMR.Tests.Utilities;
using NSubstitute;
using Shouldly;
namespace JSMR.Tests.Integrations.DLSite;
namespace JSMR.Tests.Scanning;
public class VoiceWorkScannerTests
{
@@ -14,6 +14,45 @@ public class VoiceWorkScannerTests
return await ResourceHelper.ReadAsync($"JSMR.Tests.Scanning.{resourceName}");
}
[Fact]
public async Task Scan_With_Japanese_Locale()
{
string html = await ReadResourceAsync("Japanese-Page.html");
IHttpService httpService = Substitute.For<IHttpService>();
httpService.GetStringAsync(Arg.Any<string>(), CancellationToken.None)
.Returns(Task.FromResult(html));
HtmlLoader loader = new(httpService);
JapaneseVoiceWorksScanner scanner = new(loader);
VoiceWorkScanOptions options = new(
PageNumber: 1,
PageSize: 100,
ExcludeAIGeneratedWorks: true,
ExcludePartiallyAIGeneratedWorks: true,
ExcludedMakerIds: []
);
var result = await scanner.ScanPageAsync(options, CancellationToken.None);
result.Count.ShouldBe(1);
result[0].ExpectedDate.ShouldBeNull();
result[0].SalesDate.ShouldBe(new DateOnly(2025, 10, 15));
result[0].ProductId.ShouldBe("RJ01462066");
result[0].ProductName.ShouldBe("小悪魔ドSメンズエステ嬢の暴発解禁キワキワ施術");
result[0].Description.ShouldBe("リピート指名していたオキニ嬢の在籍店が閉店し途方に暮れていた貴方だったが、ある日彼女の個人SNSで別のお店のリンクを発見する。大慌てで当日夜の予約を確保し、今度こそ抜いてくれないかと淡い期待を胸に駅近くのマンションの一室へ…。");
result[0].Maker.ShouldBe("シルトクレーテ");
result[0].MakerId.ShouldBe("RG40741");
result[0].Creators.ShouldBe(["柚木つばめ"]);
result[0].Genres.ShouldBe(["体験版"]);
result[0].Tags.ShouldBe(["バイノーラル/ダミヘ", "手コキ", "足コキ", "パイズリ", "言葉責め", "焦らし", "乳首責め", "本番なし"]);
result[0].Type.ShouldBe(DLSiteWorkType.Released);
result[0].Downloads.ShouldBe(1220);
}
[Fact]
public async Task Scan_With_English_Locale()
{
@@ -57,4 +96,43 @@ public class VoiceWorkScannerTests
result[1].ProductId.ShouldBe("RJ00000002");
result[1].Type.ShouldBe(DLSiteWorkType.Announced);
}
[Fact]
public async Task Scan_With_Updated_English_Locale()
{
string html = await ReadResourceAsync("English-Page-Updated.html");
IHttpService httpService = Substitute.For<IHttpService>();
httpService.GetStringAsync(Arg.Any<string>(), CancellationToken.None)
.Returns(Task.FromResult(html));
HtmlLoader loader = new(httpService);
EnglishVoiceWorksScanner scanner = new(loader);
VoiceWorkScanOptions options = new(
PageNumber: 1,
PageSize: 100,
ExcludeAIGeneratedWorks: true,
ExcludePartiallyAIGeneratedWorks: true,
ExcludedMakerIds: []
);
var result = await scanner.ScanPageAsync(options, CancellationToken.None);
result.Count.ShouldBe(1);
result[0].ExpectedDate.ShouldBeNull();
result[0].SalesDate.ShouldBe(new DateOnly(2025, 10, 16));
result[0].ProductId.ShouldBe("RJ01455722");
result[0].ProductName.ShouldBe("[ENG Sub] Welcome to Soleil!");
result[0].Description.ShouldBe(string.Empty); // Waiting on this to get fixed on the site
result[0].Maker.ShouldBe("Translators Unite");
result[0].MakerId.ShouldBe("RG60289");
result[0].Creators.ShouldBe(["沼倉愛美"]);
result[0].Genres.ShouldBe(["All Ages", "Trial version"]);
result[0].Tags.ShouldBe(["Moe", "Healing", "Binaural", "ASMR", "Ear Cleaning", "Slice of Life / Daily Living", "Heartwarming", "Whispering"]);
result[0].Type.ShouldBe(DLSiteWorkType.Released);
result[0].Downloads.ShouldBe(1);
}
}