mirror of
https://github.com/nsnail/Ocelot.git
synced 2025-04-22 06:22:50 +08:00
sticking send messages toself in to make this testable
This commit is contained in:
parent
4c405f0f29
commit
17a515c4c0
0
src/Ocelot/Infrastructure/InMemoryBus.cs
Normal file
0
src/Ocelot/Infrastructure/InMemoryBus.cs
Normal file
45
test/Ocelot.UnitTests/Infrastructure/InMemoryBusTests.cs
Normal file
45
test/Ocelot.UnitTests/Infrastructure/InMemoryBusTests.cs
Normal file
@ -0,0 +1,45 @@
|
|||||||
|
using System.Threading.Tasks;
|
||||||
|
using Shouldly;
|
||||||
|
using Xunit;
|
||||||
|
|
||||||
|
namespace Ocelot.UnitTests.Infrastructure
|
||||||
|
{
|
||||||
|
public class InMemoryBusTests
|
||||||
|
{
|
||||||
|
private InMemoryBus<Message> _bus;
|
||||||
|
|
||||||
|
public InMemoryBusTests()
|
||||||
|
{
|
||||||
|
_bus = new InMemoryBus<Message>();
|
||||||
|
}
|
||||||
|
|
||||||
|
[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
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user