Skip to content

Commit

Permalink
Fixing test
Browse files Browse the repository at this point in the history
  • Loading branch information
jbogard committed Feb 23, 2023
1 parent bc58da6 commit e1a6418
Showing 1 changed file with 8 additions and 16 deletions.
24 changes: 8 additions & 16 deletions test/MediatR.Tests/NotificationPublisherTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,34 +49,26 @@ public async Task Should_handle_sequentially_by_default()

timer.Stop();

timer.ElapsedMilliseconds.ShouldBeGreaterThanOrEqualTo(750);
var sequentialElapsed = timer.ElapsedMilliseconds;

_output.WriteLine(timer.ElapsedMilliseconds.ToString());
}


[Fact]
public async Task Should_handle_in_parallel_with_when_all()
{
var services = new ServiceCollection();
services = new ServiceCollection();
services.AddMediatR(cfg =>
{
cfg.RegisterServicesFromAssemblyContaining<Notification>();
cfg.NotificationPublisherType = typeof(TaskWhenAllPublisher);
});
var serviceProvider = services.BuildServiceProvider();
serviceProvider = services.BuildServiceProvider();

var mediator = serviceProvider.GetRequiredService<IMediator>();
mediator = serviceProvider.GetRequiredService<IMediator>();

var timer = new Stopwatch();
timer.Start();
timer.Restart();

await mediator.Publish(new Notification());

timer.Stop();

timer.ElapsedMilliseconds.ShouldBeLessThan(750);
_output.WriteLine(timer.ElapsedMilliseconds.ToString());
var parallelElapsed = timer.ElapsedMilliseconds;

sequentialElapsed.ShouldBeGreaterThan(parallelElapsed);
}
}

0 comments on commit e1a6418

Please sign in to comment.