diff --git a/src/Ocelot/Infrastructure/InMemoryBus.cs b/src/Ocelot/Infrastructure/InMemoryBus.cs new file mode 100644 index 00000000..e69de29b diff --git a/test/Ocelot.UnitTests/Infrastructure/InMemoryBusTests.cs b/test/Ocelot.UnitTests/Infrastructure/InMemoryBusTests.cs new file mode 100644 index 00000000..918cfb9f --- /dev/null +++ b/test/Ocelot.UnitTests/Infrastructure/InMemoryBusTests.cs @@ -0,0 +1,45 @@ +using System.Threading.Tasks; +using Shouldly; +using Xunit; + +namespace Ocelot.UnitTests.Infrastructure +{ + public class InMemoryBusTests + { + private InMemoryBus _bus; + + public InMemoryBusTests() + { + _bus = new InMemoryBus(); + } + + [Fact] + public async Task should_publish_with_delay() + { + var called = false; + _bus.Subscribe(x => { + called = true; + }); + await _bus.Publish(new Message(), 1); + await Task.Delay(10); + called.ShouldBeTrue(); + } + + [Fact] + public async Task should_not_be_publish_yet_as_no_delay_in_caller() + { + var called = false; + _bus.Subscribe(x => { + called = true; + }); + await _bus.Publish(new Message(), 1); + called.ShouldBeFalse(); + } + + + class Message + { + + } + } +}