Beispiel #1
0
        public Task CommandResult_NotRequired()
        {
            return(CommandConsumer.Test(
                       async c =>
            {
                c.Build();

                var domainEventSrv = c.Services.Resolve <IMessagingService>();
                var evt = new MockCommandNoResult();
                await domainEventSrv.PublishAsync(evt);
            },
                       (IAppContainer c) =>
            {
                var consumer = c.Services.Resolve <MockCommandConsumer>();
                consumer.ExecutedHandlers.Should().HaveCount(1);
                consumer.ExecutedHandlers.Should().Contain("OnCommandNoResult");
            }));
        }
Beispiel #2
0
        public Task CommandWithResult_FromAsyncHandler()
        {
            MockCommandResult result = null;

            return(CommandConsumer.Test(
                       async c => {
                c.Build();

                var domainEventSrv = c.Services.Resolve <IMessagingService>();
                var evt = new MockCommand();
                var futureResult = domainEventSrv.PublishAsync(evt);

                result = await futureResult;
            },
                       (IAppContainer c) => {
                result.Should().NotBeNull();
                result.Value.Should().Be("MOCK_VALUE");

                var consumer = c.Services.Resolve <MockCommandConsumer>();
                consumer.ExecutedHandlers.Should().HaveCount(1);
                consumer.ExecutedHandlers.Should().Contain("OnCommand");
            }));
        }