// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Collections.Generic; using System.Threading.Tasks; namespace Microsoft.AspNetCore.Http.Features { public class FakeResponseFeature : HttpResponseFeature { List, object>> _onCompletedCallbacks = new List, object>>(); public override void OnCompleted(Func callback, object state) { _onCompletedCallbacks.Add(new Tuple, object>(callback, state)); } public async Task CompleteAsync() { var callbacks = _onCompletedCallbacks; _onCompletedCallbacks = null; foreach (var callback in callbacks) { await callback.Item1(callback.Item2); } } } }