Skip to content

Commit c3d299d

Browse files
committed
Fail fast on handler timeout firing
1 parent 6c810b3 commit c3d299d

File tree

1 file changed

+3
-8
lines changed

1 file changed

+3
-8
lines changed

src/NServiceBus.AcceptanceTests/Core/Sagas/When_handling_message_with_handler_and_timeout_handler.cs

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -16,19 +16,13 @@ public async Task Should_not_invoke_timeout_handler()
1616
{
1717
SomeId = Guid.NewGuid()
1818
})))
19-
.Done(c => c.HandlerInvoked || c.TimeoutHandlerInvoked)
2019
.Run();
2120

22-
using (Assert.EnterMultipleScope())
23-
{
24-
Assert.That(context.HandlerInvoked, Is.True, "Regular handler should be invoked");
25-
Assert.That(context.TimeoutHandlerInvoked, Is.False, "Timeout handler should not be invoked");
26-
}
21+
Assert.That(context.HandlerInvoked, Is.True, "Regular handler should be invoked");
2722
}
2823

2924
public class Context : ScenarioContext
3025
{
31-
public bool TimeoutHandlerInvoked { get; set; }
3226
public bool HandlerInvoked { get; set; }
3327
}
3428

@@ -43,12 +37,13 @@ public class HandlerAndTimeoutSaga(Context testContext) : Saga<HandlerAndTimeout
4337
public Task Handle(StartSagaMessage message, IMessageHandlerContext context)
4438
{
4539
testContext.HandlerInvoked = true;
40+
testContext.MarkAsCompleted();
4641
return Task.CompletedTask;
4742
}
4843

4944
public Task Timeout(StartSagaMessage message, IMessageHandlerContext context)
5045
{
51-
testContext.TimeoutHandlerInvoked = true;
46+
testContext.MarkAsFailed(new InvalidOperationException("Timeout handler invoked"));
5247
return Task.CompletedTask;
5348
}
5449

0 commit comments

Comments
 (0)