public async Task CompleteAsync()
        {
            var callback1Called = false;
            var callback2Called = false;

            Func <object, Task> callback1 = (state) =>
            {
                state.Should().Be(1111);
                callback1Called = true;

                return(Task.CompletedTask);
            };

            Func <object, Task> callback2 = (state) =>
            {
                state.Should().Be("2222");
                callback2Called = true;

                return(Task.CompletedTask);
            };

            var response = new Mock <HttpResponseBase>(MockBehavior.Strict);

            var responseFeature = new HttpResponseFeature(response.Object);

            responseFeature.OnCompleted(callback1, 1111);
            responseFeature.OnCompleted(callback2, "2222");

            await responseFeature.CompleteAsync();

            callback1Called.Should().BeTrue();
            callback2Called.Should().BeTrue();
        }
Пример #2
0
        public override void OnCompleted(Func <object, Task> callback, object state)
        {
            if (callback == null)
            {
                throw new ArgumentNullException(nameof(callback));
            }

            HttpResponseFeature.OnCompleted(callback, state);
        }
 public override void OnCompleted(Func <object, Task> callback, object state)
 {
     HttpResponseFeature.OnCompleted(callback, state);
 }