public void DeadlineTimer_ExecutedAfterDispose_RequestNotAborted()
        {
            // Arrange
            var lifetimeFeature = new TestHttpRequestLifetimeFeature();

            var httpContext = new DefaultHttpContext();

            httpContext.Request.Headers[GrpcProtocolConstants.TimeoutHeader] = "1H";
            httpContext.Features.Set <IHttpRequestLifetimeFeature>(lifetimeFeature);

            var serverCallContext = CreateServerCallContext(httpContext);

            serverCallContext.Initialize();
            serverCallContext.Dispose();

            // Act
            serverCallContext.DeadlineExceeded(TimeSpan.Zero);

            // Assert
            Assert.IsFalse(lifetimeFeature.RequestAborted.IsCancellationRequested);
        }
Esempio n. 2
0
        public void CancellationToken_WithDeadlineAndRequestAborted_DeadlineStatusNotSet()
        {
            // Arrange
            var testSink   = new TestSink();
            var testLogger = new TestLogger(string.Empty, testSink, true);

            var requestLifetimeFeature = new TestHttpRequestLifetimeFeature();
            var httpContext            = new DefaultHttpContext();

            httpContext.Features.Set <IHttpRequestLifetimeFeature>(requestLifetimeFeature);
            httpContext.Request.Headers[GrpcProtocolConstants.TimeoutHeader] = "1000S";
            var context = CreateServerCallContext(httpContext, testLogger);

            context.Initialize();

            // Act
            requestLifetimeFeature.Abort();

            // Assert
            Assert.AreNotEqual(StatusCode.DeadlineExceeded, context.Status.StatusCode);
            Assert.IsTrue(context.CancellationToken.IsCancellationRequested);
        }