mirror of
https://github.com/Sea-Haven-Industries/shoc-backend.git
synced 2026-09-30 07:13:12 +00:00
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 <noreply@anthropic.com>
This commit is contained in:
parent
24ad21d7f2
commit
2be74b261f
1 changed files with 19 additions and 1 deletions
|
|
@ -18,7 +18,25 @@ public sealed class WorkOrderUpliftServiceConflictTests
|
||||||
[Fact]
|
[Fact]
|
||||||
public async Task CreateAsync_DifferentWorkOrdersSharingDispatch_MapsConcurrentInsertConflict()
|
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<DispatchWorkOrder>
|
||||||
|
{
|
||||||
|
new() { DispatchId = 10, WorkOrderId = 2 },
|
||||||
|
},
|
||||||
|
};
|
||||||
var upliftData = new Mock<IUpliftDataService>();
|
var upliftData = new Mock<IUpliftDataService>();
|
||||||
|
upliftData.Setup(x => x.GetUpliftDispatchForWorkOrderAsync(
|
||||||
|
It.IsIn(1, 2),
|
||||||
|
10,
|
||||||
|
It.IsAny<CancellationToken>()))
|
||||||
|
.ReturnsAsync(sharedDispatch);
|
||||||
var bothAtInsert = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
var bothAtInsert = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
|
||||||
var savesArrived = 0;
|
var savesArrived = 0;
|
||||||
var winner = 0;
|
var winner = 0;
|
||||||
|
|
@ -62,7 +80,7 @@ public sealed class WorkOrderUpliftServiceConflictTests
|
||||||
|
|
||||||
var dispatchData = new Mock<IDispatchDataService>();
|
var dispatchData = new Mock<IDispatchDataService>();
|
||||||
dispatchData.Setup(x => x.GetByIdAsync(10))
|
dispatchData.Setup(x => x.GetByIdAsync(10))
|
||||||
.ReturnsAsync(new Dispatch { Id = 10, Status = "Scheduled", NTEAmount = 1000m });
|
.ReturnsAsync(sharedDispatch);
|
||||||
dispatchData.Setup(x => x.StageAuditLogAsync(It.IsAny<WorkOrderAuditLog>(), It.IsAny<CancellationToken>()))
|
dispatchData.Setup(x => x.StageAuditLogAsync(It.IsAny<WorkOrderAuditLog>(), It.IsAny<CancellationToken>()))
|
||||||
.Returns(Task.CompletedTask);
|
.Returns(Task.CompletedTask);
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue