|
|
|
@ -18,7 +18,7 @@ namespace Squidex.Infrastructure.CQRS.Commands |
|
|
|
{ |
|
|
|
private readonly ICommand command = A.Fake<ICommand>(); |
|
|
|
|
|
|
|
private sealed class HandledHandler : ICommandHandler |
|
|
|
private sealed class HandledHandler : ICommandMiddleware |
|
|
|
{ |
|
|
|
public ICommand LastCommand; |
|
|
|
|
|
|
|
@ -32,7 +32,7 @@ namespace Squidex.Infrastructure.CQRS.Commands |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private sealed class NonHandledHandler : ICommandHandler |
|
|
|
private sealed class NonHandledHandler : ICommandMiddleware |
|
|
|
{ |
|
|
|
public ICommand LastCommand; |
|
|
|
|
|
|
|
@ -44,7 +44,7 @@ namespace Squidex.Infrastructure.CQRS.Commands |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
private sealed class ThrowHandledHandler : ICommandHandler |
|
|
|
private sealed class ThrowHandledHandler : ICommandMiddleware |
|
|
|
{ |
|
|
|
public ICommand LastCommand; |
|
|
|
|
|
|
|
@ -59,7 +59,7 @@ namespace Squidex.Infrastructure.CQRS.Commands |
|
|
|
[Fact] |
|
|
|
public async Task Should_not_set_handled_if_no_handler_registered() |
|
|
|
{ |
|
|
|
var sut = new InMemoryCommandBus(new ICommandHandler[0]); |
|
|
|
var sut = new InMemoryCommandBus(new ICommandMiddleware[0]); |
|
|
|
var ctx = await sut.PublishAsync(command); |
|
|
|
|
|
|
|
Assert.False(ctx.IsCompleted); |
|
|
|
@ -70,7 +70,7 @@ namespace Squidex.Infrastructure.CQRS.Commands |
|
|
|
{ |
|
|
|
var handler = new NonHandledHandler(); |
|
|
|
|
|
|
|
var sut = new InMemoryCommandBus(new ICommandHandler[] { handler }); |
|
|
|
var sut = new InMemoryCommandBus(new ICommandMiddleware[] { handler }); |
|
|
|
var ctx = await sut.PublishAsync(command); |
|
|
|
|
|
|
|
Assert.Equal(command, handler.LastCommand); |
|
|
|
@ -82,7 +82,7 @@ namespace Squidex.Infrastructure.CQRS.Commands |
|
|
|
{ |
|
|
|
var handler = new HandledHandler(); |
|
|
|
|
|
|
|
var sut = new InMemoryCommandBus(new ICommandHandler[] { handler }); |
|
|
|
var sut = new InMemoryCommandBus(new ICommandMiddleware[] { handler }); |
|
|
|
var ctx = await sut.PublishAsync(command); |
|
|
|
|
|
|
|
Assert.Equal(command, handler.LastCommand); |
|
|
|
@ -94,7 +94,7 @@ namespace Squidex.Infrastructure.CQRS.Commands |
|
|
|
{ |
|
|
|
var handler = new ThrowHandledHandler(); |
|
|
|
|
|
|
|
var sut = new InMemoryCommandBus(new ICommandHandler[] { handler }); |
|
|
|
var sut = new InMemoryCommandBus(new ICommandMiddleware[] { handler }); |
|
|
|
|
|
|
|
await Assert.ThrowsAsync<InvalidOperationException>(async () => await sut.PublishAsync(command)); |
|
|
|
|
|
|
|
|