Skip to content

Commit

Permalink
Adjust unit test wait times
Browse files Browse the repository at this point in the history
  • Loading branch information
petar-m committed Apr 30, 2024
1 parent c33eff0 commit 195a25d
Show file tree
Hide file tree
Showing 5 changed files with 9 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -93,6 +93,11 @@ private static async Task HandleEvent(object state)
var handler = context.EventHandlerDescriptor!.Handle;
var errorHandler = context.EventHandlerDescriptor!.OnError;

if(context.CancellationToken.IsCancellationRequested)
{
return;
}

object? service = null;
using var scope = context.CreateScope();
try
Expand Down
2 changes: 1 addition & 1 deletion test/M.EventBrokerSlim.Tests/EventBrokerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ public async Task Shutdown_WhileHandlingEvent_TaskCancelledException_HandledByOn
await eventBroker.Publish(@event);
}

await Task.Delay(TimeSpan.FromMilliseconds(250));
await Task.Delay(TimeSpan.FromMilliseconds(200));

eventBroker.Shutdown();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ public async Task Handler_RegisteredAsTransient_Executed_ByDifferentInstances_An
await eventBroker.Publish(event1);
await eventBroker.Publish(event2);

var completed = await eventsRecorder.WaitForExpected(timeout: TimeSpan.FromMilliseconds(50));
var completed = await eventsRecorder.WaitForExpected(timeout: TimeSpan.FromMilliseconds(100));

// Assert
Assert.True(completed);
Expand Down
2 changes: 1 addition & 1 deletion test/M.EventBrokerSlim.Tests/LoadTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public async Task Load_MultipleHandlers_With_Retry()
await eventBroker.Publish(new Event3("event", i));
}

await eventsTracker.Wait(TimeSpan.FromSeconds(2));
await eventsTracker.Wait(TimeSpan.FromSeconds(3));

// Assert
var counters = eventsTracker.Items
Expand Down
2 changes: 1 addition & 1 deletion test/M.EventBrokerSlim.Tests/MultipleHandlersTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public async Task MultipleHandlers_AllExecuted()

await eventBroker.Publish(testEvent);

var completed = await eventsRecorder.WaitForExpected(timeout: TimeSpan.FromMilliseconds(50));
var completed = await eventsRecorder.WaitForExpected(timeout: TimeSpan.FromMilliseconds(100));

// Assert
Assert.True(completed);
Expand Down

0 comments on commit 195a25d

Please sign in to comment.