From 2be74b261f8ea56e0d7ec9cb03450f7b6cd623d5 Mon Sep 17 00:00:00 2001 From: Alexandre Brandizzi Date: Thu, 24 Sep 2026 22:28:04 -0300 Subject: [PATCH] test(uplifts): share conflict fixture dispatch through owned and linked work orders After SH-393 the uplift dispatch resolves only through dispatches the work order owns or links through DispatchWorkOrders. Model the shared dispatch that way so the concurrent-insert conflict test exercises the conflict mapping again; assertions are unchanged. Co-Authored-By: Claude Opus 5.5 --- .../WorkOrderUpliftServiceConflictTests.cs | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/Api.SeaHavenIndustries.Tests/WorkOrderUpliftServiceConflictTests.cs b/Api.SeaHavenIndustries.Tests/WorkOrderUpliftServiceConflictTests.cs index 129e360..5366d8c 100644 --- a/Api.SeaHavenIndustries.Tests/WorkOrderUpliftServiceConflictTests.cs +++ b/Api.SeaHavenIndustries.Tests/WorkOrderUpliftServiceConflictTests.cs @@ -18,7 +18,25 @@ public sealed class WorkOrderUpliftServiceConflictTests [Fact] public async Task CreateAsync_DifferentWorkOrdersSharingDispatch_MapsConcurrentInsertConflict() { + // Dispatch 10 is legitimately shared: work order 1 owns it and work order 2 links to + // it through DispatchWorkOrders, so the uplift dispatch resolves to it for both. + var sharedDispatch = new Dispatch + { + Id = 10, + WorkOrderId = 1, + Status = "Scheduled", + NTEAmount = 1000m, + DispatchWorkOrders = new List + { + new() { DispatchId = 10, WorkOrderId = 2 }, + }, + }; var upliftData = new Mock(); + upliftData.Setup(x => x.GetUpliftDispatchForWorkOrderAsync( + It.IsIn(1, 2), + 10, + It.IsAny())) + .ReturnsAsync(sharedDispatch); var bothAtInsert = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously); var savesArrived = 0; var winner = 0; @@ -62,7 +80,7 @@ public sealed class WorkOrderUpliftServiceConflictTests var dispatchData = new Mock(); dispatchData.Setup(x => x.GetByIdAsync(10)) - .ReturnsAsync(new Dispatch { Id = 10, Status = "Scheduled", NTEAmount = 1000m }); + .ReturnsAsync(sharedDispatch); dispatchData.Setup(x => x.StageAuditLogAsync(It.IsAny(), It.IsAny())) .Returns(Task.CompletedTask);