< Summary

Class:Azure.Core.TestFramework.SyncAsyncPolicyTestBase
Assembly:Azure.Core.TestFramework
File(s):C:\Git\azure-sdk-for-net\sdk\core\Azure.Core.TestFramework\src\SyncAsyncPolicyTestBase.cs
Covered lines:20
Uncovered lines:0
Coverable lines:20
Total lines:55
Line coverage:100% (20 of 20)
Covered branches:6
Total branches:6
Branch coverage:100% (6 of 6)

Metrics

MethodCyclomatic complexity Line coverage Branch coverage
.ctor(...)-100%100%
SendRequestAsync()-100%100%
SendRequestAsync()-100%100%
SendGetRequest()-100%100%

File(s)

C:\Git\azure-sdk-for-net\sdk\core\Azure.Core.TestFramework\src\SyncAsyncPolicyTestBase.cs

#LineLine coverage
 1// Copyright (c) Microsoft Corporation. All rights reserved.
 2// Licensed under the MIT License.
 3
 4using System;
 5using System.Threading;
 6using System.Threading.Tasks;
 7using Azure.Core.Pipeline;
 8using NUnit.Framework;
 9
 10namespace Azure.Core.TestFramework
 11{
 12    [TestFixture(true)]
 13    [TestFixture(false)]
 14    public class SyncAsyncPolicyTestBase : SyncAsyncTestBase
 15    {
 3616        public SyncAsyncPolicyTestBase(bool isAsync) : base(isAsync)
 17        {
 3618        }
 19
 20        protected async Task<Response> SendRequestAsync(HttpPipeline pipeline, Action<Request> requestAction, bool buffe
 21        {
 130822            HttpMessage message = pipeline.CreateMessage();
 130823            message.BufferResponse = bufferResponse;
 130824            requestAction(message.Request);
 25
 130826            if (IsAsync)
 27            {
 65428                await pipeline.SendAsync(message, cancellationToken).ConfigureAwait(false);
 29            }
 30            else
 31            {
 65432                pipeline.Send(message, cancellationToken);
 33            }
 34
 83235            return message.Response;
 83236        }
 37
 38        protected async Task<Response> SendRequestAsync(HttpPipelineTransport transport, Action<Request> requestAction, 
 39        {
 122840            await Task.Yield();
 41
 122842            var pipeline = new HttpPipeline(transport, new[] { policy }, responseClassifier);
 122843            return await SendRequestAsync(pipeline, requestAction, bufferResponse, cancellationToken);
 75644        }
 45
 46        protected async Task<Response> SendGetRequest(HttpPipelineTransport transport, HttpPipelinePolicy policy, Respon
 47        {
 121648            return await SendRequestAsync(transport, request =>
 121649            {
 243250                request.Method = RequestMethod.Get;
 243251                request.Uri.Reset(uri ?? new Uri("http://example.com"));
 243252            }, policy, responseClassifier, bufferResponse, cancellationToken);
 74853        }
 54    }
 55}