public SagaSampleStateMachineTests(DefaultWebHostTestFixture fixture, ITestOutputHelper output) { _testOffset = TimeSpan.Zero; _harness = new InMemoryTestHarness(); _harness.OnConfigureInMemoryBus += ConfigureInMemoryBus; var machine = new SagaSampleStateMachine(); _stateMachineSagaTestHarness = _harness.StateMachineSaga <SagaSampleInstanceState, SagaSampleStateMachine>(machine); _harness.Start().Wait(); fixture.Output = output; _client = fixture.CreateClient(); _fixture = fixture; _output = output; var inputQueueAddress = _harness.InputQueueAddress; var requestClient = _harness.CreateRequestClient <SagaStatusRequestedEvent>(); MockedObjects.SagaStatusRequestClient.Setup(e => e.GetResponse <SagaStatus, SagaStatusNotFound>(It.IsAny <SagaStatusRequestedEvent>(), It.IsAny <CancellationToken>(), It.IsAny <RequestTimeout>())) .Returns((SagaStatusRequestedEvent o, CancellationToken token, RequestTimeout timeout) => { return(requestClient.GetResponse <SagaStatus, SagaStatusNotFound>(o)); }); MockedObjects.IPublishEndpoint.Setup(e => e.Publish(It.IsAny <SagaStartedEvent>(), It.IsAny <CancellationToken>())) .Returns((SagaStartedEvent o, CancellationToken token) => { return(_harness.Bus.Publish(o)); }); }
public async Task Should_not_timeout() { var harness = new InMemoryTestHarness(); var machine = new TestSagaStateMachine(); StateMachineSagaTestHarness <TestSaga, TestSagaStateMachine> sagaHarness = harness.StateMachineSaga <TestSaga, TestSagaStateMachine>(machine); harness.TestTimeout = TimeSpan.FromSeconds(15); harness.OnConfigureBus += x => BusTestFixture.ConfigureBusDiagnostics(x); await harness.Start(); // Act try { IRequestClient <StartCommand> client = harness.CreateRequestClient <StartCommand>(); Response <StartCommandResponse> response = await client.GetResponse <StartCommandResponse>( new { CorrelationId = InVar.Id, }); // Assert // did the actual saga consume the message Assert.True(await sagaHarness.Consumed.Any <StartCommand>()); } finally { await harness.Stop(); } }