Exemplo n.º 1
0
        public void GetHttpStatusCode_ErrorsAttached()
        {
            // Arrange
            CustomError customError = new CustomError(ErrorsCodesContants.INVALID_EMAIL_OR_PASSWORD, ErrorsMessagesConstants.INVALID_EMAIL_OR_PASSWORD, 401);
            CQException cQException = new CQException(new List <CustomError> {
                customError
            });
            CQExceptionHandler handler = new CQExceptionHandler(cQException);
            // Act
            int result = handler.GetHttpStatusCode();

            // Assert
            result.Should().Be(401);
        }
Exemplo n.º 2
0
 public CQExceptionHandler(CQException handlerException)
 {
     // TODO: Test null input value
     if (handlerException == null || !handlerException.Errors().Any())
     {
         CustomError unkownError = new CustomError(ErrorsCodesContants.UNKNOWN_ERROR_API, ErrorsMessagesConstants.UNKNOWN_ERROR_API, 500);
         _handlerException = new CQException(new List <CustomError> {
             unkownError
         });
     }
     else
     {
         _handlerException = handlerException;
     }
 }
Exemplo n.º 3
0
        public void CQExceptionHandler_ConstructorNoError_AddDefaultError()
        {
            // Arrange
            CQException cQException = new CQException(new List <CustomError>());

            CustomError unkownError = new CustomError(ErrorsCodesContants.UNKNOWN_ERROR_API, ErrorsMessagesConstants.UNKNOWN_ERROR_API, 500);
            CQException cQExceptionWithDefaultError = new CQException(new List <CustomError> {
                unkownError
            });
            // Act
            CQExceptionHandler handlerResult   = new CQExceptionHandler(cQException);
            CQExceptionHandler handlerExpected = new CQExceptionHandler(cQExceptionWithDefaultError);

            // Assert
            handlerResult.CreateResponseContent().Should().Be(handlerExpected.CreateResponseContent());
            handlerResult.GetHttpStatusCode().Should().Be(handlerExpected.GetHttpStatusCode());
        }