Beispiel #1
0
        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));
        }
Beispiel #2
0
        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));
        }
Beispiel #3
0
        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);
            }
        }