public void Builds_document_from_exception()
        {
            // Arrange
            Exception theException;
            try
            {
                throw new Exception("This is the exception!");
            }
            catch (Exception ex)
            {
                theException = ex;
            }

            // Act
            var errorDocumentBuilder = new ErrorDocumentBuilder();
            var document = errorDocumentBuilder.BuildFromException(theException);

            // Assert
            document.Errors.Length.Should().Be(1);
            var error = document.Errors.First();
            error.Id.Should().MatchRegex(GuidRegex);
            error.Title.Should().Be("Unhandled exception");
            error.Detail.Should().Be("An unhandled exception was thrown while processing the request.");
            error.Status.Should().Be(HttpStatusCode.InternalServerError);
            ((string)error.Metadata.MetaObject["exceptionMessage"]).Should().Be("This is the exception!");
            ((string)error.Metadata.MetaObject["stackTrace"]).Should().NotBeNull();
        }
        public void Builds_document_from_JsonApiException()
        {
            // Arrange
            var mockError = new Mock<IError>(MockBehavior.Strict);
            JsonApiException theException;
            try
            {
                throw new JsonApiException(mockError.Object);
            }
            catch (JsonApiException ex)
            {
                theException = ex;
            }

            // Act
            var errorDocumentBuilder = new ErrorDocumentBuilder();
            var document = errorDocumentBuilder.BuildFromException(theException);

            // Assert
            document.Errors.Length.Should().Be(1);
            document.Errors.First().Should().Be(mockError.Object);
        }