Ejemplo n.º 1
0
        Given_multiple_completed_parallel_requests_gauge_is_incremented_and_decremented_correct_number_of_times()
        {
            await Task.WhenAll(_sut.Invoke(new DefaultHttpContext()), _sut.Invoke(new DefaultHttpContext()),
                               _sut.Invoke(new DefaultHttpContext()));

            Assert.AreEqual(3, _gauge.IncrementCount);
            Assert.AreEqual(3, _gauge.DecrementCount);
            Assert.AreEqual(0, _gauge.Value);
        }
 public async Task HttpInFlight()
 {
     for (var i = 0; i < RequestCount; i++)
     {
         await _inFlightMiddleware.Invoke(new DefaultHttpContext());
     }
 }
Ejemplo n.º 3
0
        public async Task Given_request_throws_then_InFlightGauge_is_decreased()
        {
            _requestDelegate = context => throw new InvalidOperationException();
            _sut             = new HttpInFlightMiddleware(_requestDelegate, _gauge);


            await Assert.ThrowsExceptionAsync <InvalidOperationException>(() => _sut.Invoke(new DefaultHttpContext()));

            Assert.AreEqual(1, _gauge.IncrementCount);
            Assert.AreEqual(1, _gauge.DecrementCount);
            Assert.AreEqual(0, _gauge.Value);
        }