public void MsalServiceException_FromHttpResponse() { // Arrange string responseBody = JsonError; var statusCode = HttpStatusCode.BadRequest; var retryAfterSpan = new TimeSpan(3600); var httpResponse = new HttpResponseMessage(statusCode) { Content = new StringContent(responseBody) }; httpResponse.Headers.RetryAfter = new RetryConditionHeaderValue(retryAfterSpan); HttpResponse msalhttpResponse = HttpManager.CreateResponseAsync(httpResponse).Result; // Act var msalException = MsalServiceExceptionFactory.FromHttpResponse(ExCode, ExMessage, msalhttpResponse); // Assert var msalServiceException = msalException as MsalServiceException; Assert.AreEqual(ExCode, msalServiceException.ErrorCode); Assert.AreEqual(responseBody, msalServiceException.ResponseBody); Assert.AreEqual(ExMessage, msalServiceException.Message); Assert.AreEqual((int)statusCode, msalServiceException.StatusCode); Assert.AreEqual("some_suberror", msalServiceException.SubError); Assert.AreEqual(retryAfterSpan, msalServiceException.Headers.RetryAfter.Delta); ValidateExceptionProductInformation(msalException); }