本文整理匯總了C#中System.Environment.Body方法的典型用法代碼示例。如果您正苦於以下問題:C# Environment.Body方法的具體用法?C# Environment.Body怎麽用?C# Environment.Body使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Environment
的用法示例。
在下文中一共展示了Environment.Body方法的1個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: Wrapped_apps_onNext_gets_rescheduled_continuation_iff_wrapping_app_provides_continuation
public void Wrapped_apps_onNext_gets_rescheduled_continuation_iff_wrapping_app_provides_continuation()
{
var app = new StaticApp(null, null, null);
bool gotComplete = false;
int gotOnNext = 0;
Action ack0 = null;
Action ack1 = null;
var scheduler = new MockScheduler();
app.OnRequest = () => {
var env = new Environment(app.Env);
env.Body((data, ack) => {
gotOnNext++;
if (gotOnNext == 1)
ack0 = ack;
if (gotOnNext == 2)
ack1 = ack;
if (ack == null)
return false;
else
{
return true;
}
},
e => {
},
() => { gotComplete = true; });
};
var middleware = new RescheduleCallbacksMiddleware(app.Invoke, scheduler);
scheduler.Post(() =>
{
middleware.Invoke(new Environment() {
Body = (onNext, onError, onComplete) => {
onNext(default(ArraySegment<byte>), null);
onNext(default(ArraySegment<byte>), () => onComplete());
return () => { };
}
}, (status, headers, body) =>
{
},
e => { });
});
scheduler.Start();
Assert.That(gotOnNext, Is.EqualTo(2));
Assert.That(ack0, Is.Null);
Assert.That(ack1, Is.Not.Null);
// queues the continuation (which invokes onComplete) on the scheduler. onComplete should not be called yet.
ack1();
Assert.That(gotComplete, Is.False);
// now run the scheduler more. after its done onComplete should have been called.
scheduler.Start();
Assert.That(gotComplete, Is.True);
}