Updated integration testing for English and Japanese. Fixed minor voice work updater issue. Updated to XUnitV3.
This commit is contained in:
31
JSMR.Tests/Ingestion/Japanese/IngestionTestsBase.cs
Normal file
31
JSMR.Tests/Ingestion/Japanese/IngestionTestsBase.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
using JSMR.Application.Scanning.Contracts;
|
||||
using JSMR.Application.Scanning.Ports;
|
||||
using JSMR.Infrastructure.Common.Time;
|
||||
using JSMR.Infrastructure.Data;
|
||||
using JSMR.Infrastructure.Ingestion;
|
||||
using JSMR.Tests.Fixtures;
|
||||
using NSubstitute;
|
||||
|
||||
namespace JSMR.Tests.Ingestion.Japanese;
|
||||
|
||||
public abstract class IngestionTestsBase(MariaDbContainerFixture container)
|
||||
{
|
||||
protected async Task<AppDbContext> GetAppDbContextAsync()
|
||||
{
|
||||
return await MariaTestDb.CreateIsolatedAsync(
|
||||
container.RootConnectionString,
|
||||
seed: VoiceWorkIngestionSeedData.SeedAsync);
|
||||
}
|
||||
|
||||
protected static async Task<VoiceWorkUpsertResult[]> UpsertAsync(AppDbContext dbContext, DateTime dateTime, VoiceWorkIngest[] ingests)
|
||||
{
|
||||
IClock clock = Substitute.For<IClock>();
|
||||
clock.UtcNow.Returns(new DateTimeOffset(dateTime));
|
||||
|
||||
TokyoTimeProvider timeProvider = new(clock);
|
||||
|
||||
VoiceWorkUpdater updater = new(dbContext, timeProvider);
|
||||
|
||||
return await updater.UpsertAsync(ingests, TestContext.Current.CancellationToken);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
using JSMR.Application.Common;
|
||||
using JSMR.Application.Scanning.Contracts;
|
||||
using JSMR.Application.Scanning.Ports;
|
||||
using JSMR.Domain.Entities;
|
||||
using JSMR.Infrastructure.Common.SupportedLanguages;
|
||||
using JSMR.Infrastructure.Data;
|
||||
using JSMR.Tests.Fixtures;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shouldly;
|
||||
|
||||
namespace JSMR.Tests.Ingestion.Japanese;
|
||||
|
||||
public class Insert_New_Release_With_New_Tags_And_Creators_Tests(MariaDbContainerFixture container) : IngestionTestsBase(container)
|
||||
{
|
||||
[Fact]
|
||||
public async Task Insert_New_Release_With_New_Tags_And_Creators()
|
||||
{
|
||||
await using AppDbContext dbContext = await GetAppDbContextAsync();
|
||||
|
||||
VoiceWorkIngest ingest = new()
|
||||
{
|
||||
MakerId = "RG10001",
|
||||
MakerName = "New Dreams",
|
||||
ProductId = "RJ2000001",
|
||||
Title = "Day One Release",
|
||||
Description = "Releasing now.",
|
||||
Tags = ["アイドル", "メガネ"],
|
||||
Creators = ["かの仔"],
|
||||
WishlistCount = 50,
|
||||
Downloads = 10,
|
||||
HasTrial = false,
|
||||
HasDLPlay = false,
|
||||
StarRating = null,
|
||||
Votes = null,
|
||||
AgeRating = AgeRating.AllAges,
|
||||
HasImage = true,
|
||||
SupportedLanguages = [new JapaneseLanguage()],
|
||||
SalesDate = new DateOnly(2025, 1, 15),
|
||||
ExpectedDate = null
|
||||
};
|
||||
|
||||
VoiceWorkUpsertResult[] results = await UpsertAsync(dbContext, new DateTime(2025, 01, 15, 9, 0, 0), [ingest]);
|
||||
|
||||
VoiceWork? voiceWork = await dbContext.VoiceWorks.SingleAsync(v => v.ProductId == "RJ2000001", TestContext.Current.CancellationToken);
|
||||
voiceWork.ShouldNotBeNull();
|
||||
voiceWork.ProductName.ShouldBe("Day One Release");
|
||||
voiceWork.Description.ShouldBe("Releasing now.");
|
||||
voiceWork.SalesDate.ShouldNotBeNull();
|
||||
voiceWork.ExpectedDate.ShouldBeNull();
|
||||
voiceWork.Status.ShouldBe((byte)VoiceWorkStatus.NewRelease);
|
||||
|
||||
voiceWork.Circle.ShouldNotBeNull();
|
||||
voiceWork.Circle.MakerId.ShouldBe("RG10001");
|
||||
voiceWork.Circle.Name.ShouldBe("New Dreams");
|
||||
|
||||
voiceWork.Tags.OrderBy(t => t.Position).Select(vwt => vwt.Tag?.Name).ToArray()
|
||||
.ShouldBe(["アイドル", "メガネ"]);
|
||||
|
||||
voiceWork.Creators.OrderBy(c => c.Position).Select(vwc => vwc.Creator?.Name).ToArray()
|
||||
.ShouldBe(["かの仔"]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,63 @@
|
||||
using JSMR.Application.Common;
|
||||
using JSMR.Application.Scanning.Contracts;
|
||||
using JSMR.Application.Scanning.Ports;
|
||||
using JSMR.Domain.Entities;
|
||||
using JSMR.Infrastructure.Common.SupportedLanguages;
|
||||
using JSMR.Infrastructure.Data;
|
||||
using JSMR.Tests.Fixtures;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shouldly;
|
||||
|
||||
namespace JSMR.Tests.Ingestion.Japanese;
|
||||
|
||||
public class Insert_New_Upcoming_With_Existing_Tags_And_Creators_Tests(MariaDbContainerFixture container) : IngestionTestsBase(container)
|
||||
{
|
||||
[Fact]
|
||||
public async Task Insert_New_Upcoming_With_Existing_Tags_And_Creators()
|
||||
{
|
||||
VoiceWorkIngest[] insertNewUpcomingIngests =
|
||||
[
|
||||
new()
|
||||
{
|
||||
MakerId = "RG00001",
|
||||
MakerName = "Good Dreams",
|
||||
ProductId = "RJ1000001",
|
||||
Title = "Brand New Preview",
|
||||
Description = "Teaser only.",
|
||||
Tags = ["ASMR", "メイド" ],
|
||||
Creators = ["秋野かえで"],
|
||||
WishlistCount = 250,
|
||||
Downloads = 0,
|
||||
HasTrial = false,
|
||||
HasDLPlay = false,
|
||||
StarRating = null,
|
||||
Votes = null,
|
||||
AgeRating = AgeRating.R15,
|
||||
HasImage = true,
|
||||
SupportedLanguages = [new JapaneseLanguage()],
|
||||
SalesDate = null,
|
||||
ExpectedDate = new DateOnly(2025, 1, 20),
|
||||
RegistrationDate = null
|
||||
}
|
||||
];
|
||||
|
||||
await using AppDbContext dbContext = await GetAppDbContextAsync();
|
||||
DateTime currentDateTime = new(2025, 01, 05, 10, 0, 0);
|
||||
|
||||
VoiceWorkUpsertResult[] results = await UpsertAsync(dbContext, currentDateTime, insertNewUpcomingIngests);
|
||||
|
||||
VoiceWork? voiceWork = await dbContext.VoiceWorks.SingleAsync(v => v.ProductId == "RJ1000001", TestContext.Current.CancellationToken);
|
||||
voiceWork.ShouldNotBeNull();
|
||||
voiceWork.ProductName.ShouldBe("Brand New Preview");
|
||||
voiceWork.Description.ShouldBe("Teaser only.");
|
||||
voiceWork.SalesDate.ShouldBeNull();
|
||||
voiceWork.ExpectedDate.ShouldNotBeNull();
|
||||
voiceWork.Status.ShouldBe((byte)VoiceWorkStatus.NewAndUpcoming);
|
||||
|
||||
voiceWork.Tags.OrderBy(t => t.Position).Select(vwt => vwt.Tag?.Name).ToArray()
|
||||
.ShouldBe(["ASMR", "メイド"]);
|
||||
|
||||
voiceWork.Creators.OrderBy(c => c.Position).Select(vwc => vwc.Creator?.Name).ToArray()
|
||||
.ShouldBe(["秋野かえで"]);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,49 @@
|
||||
using JSMR.Application.Common;
|
||||
using JSMR.Application.Scanning.Contracts;
|
||||
using JSMR.Domain.Entities;
|
||||
using JSMR.Infrastructure.Common.SupportedLanguages;
|
||||
using JSMR.Infrastructure.Data;
|
||||
using JSMR.Tests.Fixtures;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using Shouldly;
|
||||
|
||||
namespace JSMR.Tests.Ingestion.Japanese;
|
||||
|
||||
public class Insert_Upcoming_And_Scan_Again_Later_Tests(MariaDbContainerFixture container) : IngestionTestsBase(container)
|
||||
{
|
||||
[Fact]
|
||||
public async Task Insert_Upcoming_And_Scan_Again_Later()
|
||||
{
|
||||
await using AppDbContext dbContext = await GetAppDbContextAsync();
|
||||
|
||||
VoiceWorkIngest ingest = new()
|
||||
{
|
||||
MakerId = "RG00001",
|
||||
MakerName = "Good Dreams",
|
||||
ProductId = "RJ1000002",
|
||||
Title = "Preview Only",
|
||||
Description = "Still upcoming.",
|
||||
Tags = Array.Empty<string>(),
|
||||
Creators = Array.Empty<string>(),
|
||||
WishlistCount = 100,
|
||||
Downloads = 0,
|
||||
HasTrial = false,
|
||||
HasDLPlay = false,
|
||||
AgeRating = AgeRating.AllAges,
|
||||
HasImage = false,
|
||||
SupportedLanguages = [new JapaneseLanguage()],
|
||||
SalesDate = null,
|
||||
ExpectedDate = new DateOnly(2025, 2, 1)
|
||||
};
|
||||
|
||||
await UpsertAsync(dbContext, new DateTime(2025, 01, 10, 1, 0, 0), [ingest]);
|
||||
|
||||
VoiceWork? voiceWork = await dbContext.VoiceWorks.SingleAsync(v => v.ProductId == "RJ1000002", TestContext.Current.CancellationToken);
|
||||
voiceWork.Status.ShouldBe((byte)VoiceWorkStatus.NewAndUpcoming);
|
||||
|
||||
await UpsertAsync(dbContext, new DateTime(2025, 01, 12, 10, 0, 0), [ingest]);
|
||||
|
||||
VoiceWork? updatedVoiceWork = await dbContext.VoiceWorks.SingleAsync(v => v.ProductId == "RJ1000002", TestContext.Current.CancellationToken);
|
||||
updatedVoiceWork.Status.ShouldBe((byte)VoiceWorkStatus.Upcoming);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user