public void Conflate_must_restart_when_seed_throws_and_a_RestartDescider_is_used()
{
var sourceProbe = TestPublisher.CreateProbe<int>(this);
var sinkProbe = TestSubscriber.CreateManualProbe<int>(this);
var exceptionlath = new TestLatch();
var graph = Source.FromPublisher(sourceProbe).ConflateWithSeed(i =>
{
if (i%2 == 0)
{
exceptionlath.Open();
throw new TestException("I hate even seed numbers");
}
return i;
}, (sum, i) => sum + i)
.WithAttributes(ActorAttributes.CreateSupervisionStrategy(Deciders.RestartingDecider))
.To(Sink.FromSubscriber(sinkProbe))
.WithAttributes(Attributes.CreateInputBuffer(1, 1));
RunnableGraph.FromGraph(graph).Run(Materializer);
var sub = sourceProbe.ExpectSubscription();
var sinkSub = sinkProbe.ExpectSubscription();
// push the first value
sub.ExpectRequest(1);
sub.SendNext(1);
// and consume it, so that the next element
// will trigger seed
sinkSub.Request(1);
sinkProbe.ExpectNext(1);
sub.ExpectRequest(1);
sub.SendNext(2);
// make sure the seed exception happened
// before going any further
exceptionlath.Ready(TimeSpan.FromSeconds(3));
sub.ExpectRequest(1);
sub.SendNext(3);
// now we should have lost the 2 and the accumulated state
sinkSub.Request(1);
sinkProbe.ExpectNext(3);
}