Пример #1
0
        private static void ConfirmTimeoutWasSetInterceptor(Protocol.IBatchRequest request, TimeSpan expectedClientTimeout, int expectedServerTimoutInSeconds)
        {
            //We know the request wil be a GetPool request
            var getPoolRequest = (Protocol.BatchRequest <
                                      Protocol.Models.PoolGetOptions,
                                      AzureOperationResponse <Protocol.Models.CloudPool, Protocol.Models.PoolGetHeaders> >)request;

            //Override the service requset function to avoid actually going to the server
            getPoolRequest.ServiceRequestFunc = (token) =>
            {
                Assert.Equal(expectedServerTimoutInSeconds, getPoolRequest.Options.Timeout);
                Assert.Equal(expectedClientTimeout, request.Timeout);

                return(Task.FromResult(new AzureOperationResponse <Protocol.Models.CloudPool, Protocol.Models.PoolGetHeaders> {
                    Body = new Protocol.Models.CloudPool()
                }));
            };
        }
Пример #2
0
            private Task <IAzureOperationResponse> ResponseInterceptHandler(IAzureOperationResponse response, Protocol.IBatchRequest request)
            {
                this.stopwatch.Stop();

                return(Task.FromResult(response));
            }
Пример #3
0
 private void RequestInterceptHandler(Protocol.IBatchRequest request)
 {
     this.stopwatch.Reset();
     this.stopwatch.Start();
 }
Пример #4
0
        private static void VerifyODataClausesAndReturnMultiplePages <TPage, TListOptions, TListNextOptions, THeaders>(Protocol.IBatchRequest req, ODATADetailLevel expectedDetailLevel)
            where TListOptions : Protocol.Models.IOptions, new()
            where TListNextOptions : Protocol.Models.IOptions, new()
        {
            var listRequest     = req as Protocol.BatchRequest <TListOptions, AzureOperationResponse <IPage <TPage>, THeaders> >;
            var listNextRequest = req as Protocol.BatchRequest <TListNextOptions, AzureOperationResponse <IPage <TPage>, THeaders> >;

            if (listRequest != null)
            {
                listRequest.ServiceRequestFunc = token =>
                {
                    var filter = listRequest.Options as Protocol.Models.IODataFilter;
                    var select = listRequest.Options as Protocol.Models.IODataSelect;
                    var expand = listRequest.Options as Protocol.Models.IODataExpand;

                    Assert.Equal(expectedDetailLevel.FilterClause, filter?.Filter);
                    Assert.Equal(expectedDetailLevel.SelectClause, select?.Select);
                    Assert.Equal(expectedDetailLevel.ExpandClause, expand?.Expand);

                    return(Task.FromResult(new AzureOperationResponse <IPage <TPage>, THeaders>()
                    {
                        Body = new FakePage <TPage>(new List <TPage>(), "Bar")
                    }));
                };
            }

            if (listNextRequest != null)
            {
                listNextRequest.ServiceRequestFunc = token =>
                {
                    return(Task.FromResult(new AzureOperationResponse <IPage <TPage>, THeaders>()
                    {
                        Body = new FakePage <TPage>(new List <TPage>())
                    }));
                };
            }
        }