Esempio n. 1
0
        public async Task Test()
        {
            var context = new TestActionContext(
                httpApi: null,
                httpApiConfig: new HttpApiConfig(),
                apiActionDescriptor: new ApiActionDescriptor(typeof(IMyApi).GetMethod("PostAsync")));

            var parameter             = context.ApiActionDescriptor.Parameters[0];
            IApiParameterable timeout = new Timeout(50);
            await timeout.BeforeRequestAsync(context, parameter);

            await Task.Delay(100);

            var canceled = context.CancellationTokens[0].IsCancellationRequested;

            Assert.True(canceled);
        }
Esempio n. 2
0
        public async Task Test()
        {
            var context = new ApiActionContext
            {
                RequestMessage = new HttpApiRequestMessage
                {
                    RequestUri = new Uri("http://www.mywebapi.com"),
                    Method     = HttpMethod.Post
                },
                ApiActionDescriptor = ApiDescriptorCache.GetApiActionDescriptor(typeof(IMyApi).GetMethod("PostAsync"))
            };

            var parameter             = context.ApiActionDescriptor.Parameters[0];
            IApiParameterable timeout = new Timeout(5000);
            await timeout.BeforeRequestAsync(context, parameter);

            Assert.True(context.RequestMessage.Timeout == TimeSpan.FromMilliseconds(5000));
        }
Esempio n. 3
0
        public async Task Test()
        {
            var context = new ApiActionContext
            {
                RequestMessage = new HttpApiRequestMessage
                {
                    RequestUri = new Uri("http://www.mywebapi.com"),
                    Method     = HttpMethod.Post
                },
                ApiActionDescriptor = ApiDescriptorCache.GetApiActionDescriptor(typeof(IMyApi).GetMethod("PostAsync"))
            };

            var parameter             = context.ApiActionDescriptor.Parameters[0];
            IApiParameterable timeout = new Timeout(50);
            await timeout.BeforeRequestAsync(context, parameter);

            await Task.Delay(100);

            var canceled = context.CancellationTokens[0].IsCancellationRequested;

            Assert.True(canceled);
        }