| | 1 | | // Copyright (c) Microsoft Corporation. All rights reserved. |
| | 2 | | // Licensed under the MIT License. |
| | 3 | |
|
| | 4 | | using System; |
| | 5 | | using System.IO; |
| | 6 | |
|
| | 7 | | namespace Azure.Core.TestFramework |
| | 8 | | { |
| | 9 | | public class SyncAsyncTestBase |
| | 10 | | { |
| 1848 | 11 | | public bool IsAsync { get; } |
| | 12 | |
|
| 40 | 13 | | public SyncAsyncTestBase(bool isAsync) |
| | 14 | | { |
| 40 | 15 | | IsAsync = isAsync; |
| 40 | 16 | | } |
| | 17 | |
|
| | 18 | | protected MockTransport CreateMockTransport() |
| | 19 | | { |
| 104 | 20 | | return new MockTransport() |
| 104 | 21 | | { |
| 104 | 22 | | ExpectSyncPipeline = !IsAsync |
| 104 | 23 | | }; |
| | 24 | | } |
| | 25 | |
|
| | 26 | | protected MockTransport CreateMockTransport(Func<MockRequest, MockResponse> responseFactory) |
| | 27 | | { |
| 36 | 28 | | return new MockTransport(responseFactory) |
| 36 | 29 | | { |
| 36 | 30 | | ExpectSyncPipeline = !IsAsync |
| 36 | 31 | | }; |
| | 32 | | } |
| | 33 | |
|
| | 34 | | protected MockTransport CreateMockTransport(params MockResponse[] responses) |
| | 35 | | { |
| 182 | 36 | | return new MockTransport(responses) |
| 182 | 37 | | { |
| 182 | 38 | | ExpectSyncPipeline = !IsAsync |
| 182 | 39 | | }; |
| | 40 | | } |
| | 41 | |
|
| | 42 | | protected Stream WrapStream(Stream stream) |
| | 43 | | { |
| 0 | 44 | | return new AsyncValidatingStream(IsAsync, stream); |
| | 45 | | } |
| | 46 | | } |
| | 47 | | } |