public Task CanSendCommand_WithAsyncHandler_ReturningResult() { MockCommandResult cmdResult = null; return(ContainerFixture.TestAsync(async fixture => { var testResult = await fixture.Arrange .Container(c => c.WithHostCommandConsumer()) .Act.OnServices(async s => { var messagingSrv = s.GetService <IMessagingService>(); var cmd = new MockCommand(); cmdResult = await messagingSrv.SendAsync(cmd); }); testResult.Assert.Services(s => { cmdResult.Should().NotBeNull(); cmdResult.Value.Should().Be("MOCK_VALUE"); var consumer = s.GetRequiredService <MockCommandConsumer>(); consumer.ExecutedHandlers.Should().HaveCount(1); consumer.ExecutedHandlers.Should().Contain("OnCommand"); }); })); }
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"); })); }