using JSMR.Application.Scanning.Contracts; using JSMR.Infrastructure.Common.Time; using JSMR.Infrastructure.Data; using JSMR.Infrastructure.Ingestion; using JSMR.Tests.Fixtures; using NSubstitute; using Shouldly; namespace JSMR.Tests.Integration; public class VoiceWorkUpsertTests(VoiceWorkUpsertFixture fixture) : IClassFixture { [Fact] public async Task Simple_Upsert() { await using AppDbContext context = fixture.CreateDbContext(); VoiceWorkIngest[] ingests = [ new() { MakerId = "RG00001", MakerName = "Good Dreams", ProductId = "A Newly Announced Work", Title = "", Description = "" }, new() { MakerId = "RG00001", MakerName = "Sweet Dreams", ProductId = "", Title = "", Description = "" } ]; IClock clock = Substitute.For(); clock.UtcNow.Returns(new DateTimeOffset(2025, 10, 1, 0, 0, 0, 0, TimeSpan.FromSeconds(0))); TokyoTimeProvider timeProvider = new(clock); VoiceWorkUpdater updater = new(context, timeProvider); await updater.UpsertAsync(ingests, CancellationToken.None); context.VoiceWorks.Count().ShouldBe(2); } }