public void CanInterceptNestedMessages() => AsyncContext.Run(async () =>
{
var normalInterceptions = 0;
var nestedInterceptions = 0;
const int expected = 123;
using (var loop = new MessageLoop<int>(() => expected, interceptor: (i, ctx) =>
{
if (ctx.NestedMessage) nestedInterceptions++;
else normalInterceptions++;
return ctx.Func(i);
}))
{
var x = await loop.GetAsync(async n => await loop.GetAsync(async n2 => await loop.GetAsync(n3 => n3)));
Assert.AreEqual(expected, x);
Assert.AreEqual(1, normalInterceptions);
Assert.AreEqual(2, nestedInterceptions);
}
});
}