Last active
June 22, 2018 21:04
-
-
Save danesparza/19a181f81541770e6f7c401577593bf5 to your computer and use it in GitHub Desktop.
Handling AggregateExceptions from Task execution
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[TestMethod] | |
public void GetCSRInfo_BadOperation_ThrowsExceptionAndIsHandled() | |
{ | |
// Arrange | |
var uscAPI = RestService.For<IUscApi>(_uscapiurl); | |
string csrCode = "404"; | |
// Act | |
try | |
{ | |
CsrInfo item = uscAPI.GetCSRInfo(csrCode).Result.FirstOrDefault(); | |
} | |
catch (AggregateException ae) | |
{ | |
ae.Handle((x) => | |
{ | |
Debug.WriteLine("There was a problem getting the CSR information: " + x.Message); | |
// Assert | |
Assert.IsTrue(x is ApiException); | |
return true; | |
}); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment