Fixed date time assignments when testing ingestions. Added more ingestion tests. Fixed voice work updater bugs.

This commit is contained in:
2025-10-29 00:49:53 -04:00
parent 6d090390b0
commit 512da985fa
8 changed files with 242 additions and 58 deletions

View File

@@ -5,6 +5,7 @@ using JSMR.Infrastructure.Data;
using JSMR.Infrastructure.Ingestion;
using JSMR.Tests.Fixtures;
using NSubstitute;
using System.Runtime.InteropServices;
namespace JSMR.Tests.Ingestion.Japanese;
@@ -19,8 +20,10 @@ public abstract class IngestionTestsBase(MariaDbContainerFixture container)
protected static async Task<VoiceWorkUpsertResult[]> UpsertAsync(AppDbContext dbContext, DateTime dateTime, VoiceWorkIngest[] ingests)
{
DateTime utcDateTime = DateTime.SpecifyKind(dateTime, DateTimeKind.Utc);
IClock clock = Substitute.For<IClock>();
clock.UtcNow.Returns(new DateTimeOffset(dateTime));
clock.UtcNow.Returns(new DateTimeOffset(utcDateTime));
TokyoTimeProvider timeProvider = new(clock);
@@ -28,4 +31,15 @@ public abstract class IngestionTestsBase(MariaDbContainerFixture container)
return await updater.UpsertAsync(ingests, TestContext.Current.CancellationToken);
}
protected static DateTime TokyoLocalToUtc(int year, int month, int day, int hour, int minute, int second)
{
var tokyo = TimeZoneInfo.FindSystemTimeZoneById(
RuntimeInformation.IsOSPlatform(OSPlatform.Windows) ? "Tokyo Standard Time" : "Asia/Tokyo");
var localUnspec = new DateTime(year, month, day, hour, minute, second, DateTimeKind.Unspecified);
var utc = TimeZoneInfo.ConvertTimeToUtc(localUnspec, tokyo);
return utc;
}
}