LEFT | RIGHT |
1 /* | 1 /* |
2 Copyright 2013 Google Inc | 2 Copyright 2013 Google Inc |
3 | 3 |
4 Licensed under the Apache License, Version 2.0 (the "License"); | 4 Licensed under the Apache License, Version 2.0 (the "License"); |
5 you may not use this file except in compliance with the License. | 5 you may not use this file except in compliance with the License. |
6 You may obtain a copy of the License at | 6 You may obtain a copy of the License at |
7 | 7 |
8 http://www.apache.org/licenses/LICENSE-2.0 | 8 http://www.apache.org/licenses/LICENSE-2.0 |
9 | 9 |
10 Unless required by applicable law or agreed to in writing, software | 10 Unless required by applicable law or agreed to in writing, software |
11 distributed under the License is distributed on an "AS IS" BASIS, | 11 distributed under the License is distributed on an "AS IS" BASIS, |
12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 12 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
13 See the License for the specific language governing permissions and | 13 See the License for the specific language governing permissions and |
14 limitations under the License. | 14 limitations under the License. |
15 */ | 15 */ |
16 | 16 |
17 using System; | 17 using System; |
18 using System.Collections.Generic; | 18 using System.Collections.Generic; |
19 using System.Threading; | 19 using System.Threading; |
20 using System.Threading.Tasks; | 20 using System.Threading.Tasks; |
21 | 21 |
22 using Google.Apis.Http; | 22 using Google.Apis.Http; |
23 using Google.Apis.Util; | 23 using Google.Apis.Util; |
24 | 24 |
25 namespace Google.Apis.Testing | 25 namespace Google.Apis.Testing |
26 { | 26 { |
27 /// <summary> Base mock back-off handler which contains a list of all waited
time spans. </summary> | 27 /// <summary>Base mock back-off handler which contains a list of all waited
time spans.</summary> |
28 public class MockBackOffHandler : BackOffHandler | 28 public class MockBackOffHandler : BackOffHandler |
29 { | 29 { |
30 /// <summary> A list of all the waited time spans. </summary> | 30 /// <summary>A list of all the waited time spans.</summary> |
31 public List<TimeSpan> Waits { get; set; } | 31 public List<TimeSpan> Waits { get; set; } |
32 | 32 |
33 /// <summary> Constructs a new back-off handler by the given back-off. <
/summary> | 33 /// <summary>Constructs a new back-off handler by the given back-off.</s
ummary> |
34 public MockBackOffHandler(IBackOff backOff) | 34 public MockBackOffHandler(IBackOff backOff) |
35 : base(backOff) | 35 : base(backOff) |
36 { | 36 { |
37 Waits = new List<TimeSpan>(); | 37 Waits = new List<TimeSpan>(); |
38 } | 38 } |
39 | 39 |
40 /// <summary> Constructs a new back-off handler by the given initializer
. </summary> | 40 /// <summary>Constructs a new back-off handler by the given initializer.
</summary> |
41 public MockBackOffHandler(BackOffHandler.Initializer initializer) | 41 public MockBackOffHandler(BackOffHandler.Initializer initializer) |
42 : base(initializer) | 42 : base(initializer) |
43 { | 43 { |
44 Waits = new List<TimeSpan>(); | 44 Waits = new List<TimeSpan>(); |
45 } | 45 } |
46 | 46 |
47 protected override Task Wait(TimeSpan ts, CancellationToken cancellation
Token) | 47 protected override Task Wait(TimeSpan ts, CancellationToken cancellation
Token) |
48 { | 48 { |
49 Waits.Add(ts); | 49 Waits.Add(ts); |
50 return TaskEx.Delay(0); | 50 return TaskEx.Delay(0); |
51 } | 51 } |
52 } | 52 } |
53 } | 53 } |
LEFT | RIGHT |