Test case in flow example proves the previous fix works - closes #21
This commit is contained in:
parent
0b7c84a119
commit
fa231bcc64
@ -19,7 +19,7 @@ namespace _03_FlowRequestResponse
|
||||
|
||||
container.Register<ILogger, ConsoleLogger>();
|
||||
|
||||
var helper = new ExampleConsoleApp(dependencyResolver);
|
||||
var helper = new ExampleConsoleApp(dependencyResolver, 2);
|
||||
helper.Run(MainAsync);
|
||||
}
|
||||
|
||||
|
@ -65,9 +65,30 @@ namespace _03_FlowRequestResponse
|
||||
Console.WriteLine("[SimpleFlowController] Quote: " + message.Quote);
|
||||
|
||||
|
||||
// Test for issue #21: Same request/response twice in flow does not continue
|
||||
return flowProvider.YieldWithRequestSync<QuoteRequestMessage, QuoteResponseMessage>(
|
||||
new QuoteRequestMessage
|
||||
{
|
||||
Amount = 42
|
||||
},
|
||||
HandleQuoteResponse2);
|
||||
|
||||
|
||||
//exampleState.Done();
|
||||
//return flowProvider.End();
|
||||
}
|
||||
|
||||
|
||||
|
||||
[Continuation]
|
||||
public IYieldPoint HandleQuoteResponse2(QuoteResponseMessage message)
|
||||
{
|
||||
Console.WriteLine("[SimpleFlowController] Quote 2: " + message.Quote);
|
||||
|
||||
exampleState.Done();
|
||||
|
||||
return flowProvider.End();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,4 +1,5 @@
|
||||
using System;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using Tapeti;
|
||||
|
||||
@ -21,13 +22,17 @@ namespace ExampleLib
|
||||
public class ExampleConsoleApp
|
||||
{
|
||||
private readonly IDependencyContainer dependencyResolver;
|
||||
private readonly int expectedDoneCount;
|
||||
private int doneCount = 0;
|
||||
private readonly TaskCompletionSource<bool> doneSignal = new TaskCompletionSource<bool>();
|
||||
|
||||
|
||||
/// <param name="dependencyResolver">Uses Tapeti's IDependencyContainer interface so you can easily switch an example to your favourite IoC container</param>
|
||||
public ExampleConsoleApp(IDependencyContainer dependencyResolver)
|
||||
public ExampleConsoleApp(IDependencyContainer dependencyResolver, int expectedDoneCount = 1)
|
||||
{
|
||||
this.dependencyResolver = dependencyResolver;
|
||||
this.expectedDoneCount = expectedDoneCount;
|
||||
|
||||
dependencyResolver.RegisterDefault<IExampleState>(() => new ExampleState(this));
|
||||
}
|
||||
|
||||
@ -85,6 +90,7 @@ namespace ExampleLib
|
||||
|
||||
internal void Done()
|
||||
{
|
||||
if (Interlocked.Increment(ref doneCount) == expectedDoneCount)
|
||||
doneSignal.TrySetResult(true);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user