public void TryReceivePostAndReply_with_TryScan_timeout(int timeout)
{
// Given
var mb = MailboxProcessor.Start<IReplyChannel<int?>>(async inbox =>
{
var replyChannel = await inbox.TryReceive();
if (replyChannel == null)
{
Assert.True(false);
return;
}
var scanRes = await inbox.TryScan(__ =>
{
Assert.True(false, "Should have timedout");
return Task.FromResult(inbox);
}, timeout);
if (scanRes == null)
{
replyChannel.Reply(200);
}
else
{
Assert.True(false, "TryScan should have failed");
}
});
// When
var result1 = mb.PostAndReply<int?>(channel => channel);
// Then
Assert.Equal(200, result1);
}