OLD | NEW |
1 /* | 1 /* |
2 Copyright 2011 Google Inc | 2 Copyright 2011 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 |
(...skipping 383 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
394 { | 394 { |
395 request.ExecuteAsync(handler.CancellationTokenSource.Token).
Wait(); | 395 request.ExecuteAsync(handler.CancellationTokenSource.Token).
Wait(); |
396 Assert.Fail(); | 396 Assert.Fail(); |
397 } | 397 } |
398 catch (AggregateException ex) | 398 catch (AggregateException ex) |
399 { | 399 { |
400 if (ex.InnerException is TaskCanceledException) | 400 if (ex.InnerException is TaskCanceledException) |
401 { | 401 { |
402 // we expect a task canceled exception in case the cance
led request is less or equal total | 402 // we expect a task canceled exception in case the cance
led request is less or equal total |
403 // number of retries | 403 // number of retries |
404 Assert.False(cancelRequestNum > service.HttpClient.Messa
geHandler.NumTries); | 404 Assert.False(cancelRequestNum > service.HttpClient.Messa
geHandler.NumRedirects 1); |
405 } | 405 } |
406 else | 406 else |
407 { | 407 { |
408 // exception should be thrown as a result of casting to
MockResponse object | 408 // exception should be thrown as a result of casting to
MockResponse object |
409 Assert.True(cancelRequestNum > service.HttpClient.Messag
eHandler.NumTries); | 409 Assert.True(cancelRequestNum > service.HttpClient.Messag
eHandler.NumRedirects 1); |
410 } | 410 } |
411 } | 411 } |
412 | 412 |
413 var expectedCalls = Math.Min(service.HttpClient.MessageHandler.N
umTries, cancelRequestNum); | 413 var expectedCalls = Math.Min(service.HttpClient.MessageHandler.N
umRedirects 1, cancelRequestNum); |
414 Assert.That(handler.Calls, Is.EqualTo(expectedCalls)); | 414 Assert.That(handler.Calls, Is.EqualTo(expectedCalls)); |
415 } | 415 } |
416 } | 416 } |
417 | 417 |
418 [Test] | 418 [Test] |
419 public void Execute_DisposeService() | 419 public void Execute_DisposeService() |
420 { | 420 { |
421 var handler = new MockMessageHandler(); | 421 var handler = new MockMessageHandler(); |
422 var initializer = new BaseClientService.Initializer() | 422 var initializer = new BaseClientService.Initializer() |
423 { | 423 { |
(...skipping 689 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1113 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Post)); | 1113 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Post)); |
1114 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Patch)); | 1114 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Patch)); |
1115 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Put)); | 1115 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Put)); |
1116 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Delete)); | 1116 Assert.AreEqual(ETagAction.IfMatch, ClientServiceRequest<object>.Get
DefaultETagAction(HttpConsts.Delete)); |
1117 Assert.AreEqual(ETagAction.Ignore, ClientServiceRequest<object>.GetD
efaultETagAction("INVALID")); | 1117 Assert.AreEqual(ETagAction.Ignore, ClientServiceRequest<object>.GetD
efaultETagAction("INVALID")); |
1118 } | 1118 } |
1119 | 1119 |
1120 #endregion | 1120 #endregion |
1121 } | 1121 } |
1122 } | 1122 } |
OLD | NEW |