public async Task ContentIsUsed() { var responseBodyContent = Guid.NewGuid().ToString(); var responseMessage = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(responseBodyContent, Encoding.UTF8) }; var fulcrumError = await ExceptionConverter.ToFulcrumErrorAsync(responseMessage); Assert.IsNotNull(fulcrumError); Assert.IsTrue(fulcrumError.TechnicalMessage.Contains(responseBodyContent)); }
public async Task ContentIsTruncated() { var responseBodyContent = new string('x', 1000); var responseMessage = new HttpResponseMessage(HttpStatusCode.InternalServerError) { Content = new StringContent(responseBodyContent, Encoding.UTF8) }; var fulcrumError = await ExceptionConverter.ToFulcrumErrorAsync(responseMessage); Assert.IsNotNull(fulcrumError); Assert.IsTrue(fulcrumError.TechnicalMessage.Length < 1000); var smallContent = responseBodyContent.Substring(0, 100); Assert.IsTrue(fulcrumError.TechnicalMessage.Contains(smallContent)); }
private static async Task Verify(HttpStatusCode statusCode, string expectedType) { var responseMessage = new HttpResponseMessage(statusCode) { Content = new StringContent("Response body content", Encoding.UTF8) }; var fulcrumError = await ExceptionConverter.ToFulcrumErrorAsync(responseMessage); if (expectedType == null) { Assert.IsNull(fulcrumError); } else { Assert.IsNotNull(fulcrumError); Assert.AreEqual(expectedType, fulcrumError.Type); } }