48 lines
1.4 KiB
C#
48 lines
1.4 KiB
C#
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<VoiceWorkUpsertFixture>
|
|
{
|
|
[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<IClock>();
|
|
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);
|
|
}
|
|
} |