Fixed date time assignments when testing ingestions. Added more ingestion tests. Fixed voice work updater bugs.
This commit is contained in:
@@ -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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user