/**
  Test raising all kinds of "built-in" OO errors to check that they can be created and
  serialized correctly.
*/
USING Progress.Lang.*.

ROUTINE-LEVEL ON ERROR UNDO, THROW.

CLASS unittests.TestErrorSending:
   
   @Test.
   // ProError has no constructors. This will this compile, but cause error 14477 IN runtime.
   // So ignore this test
   @Ignore.
   METHOD PUBLIC VOID TestProError():
      RETURN ERROR NEW ProError().
   END METHOD. 
 
   /**
    * Send AppError with default message and code
    */
   @Test.
   METHOD PUBLIC VOID TestAppErrorEmpty():
      RETURN ERROR NEW AppError().
   END METHOD. 
 
   /**
    * Send AppError with the message set
    */
   @Test.
   METHOD PUBLIC VOID TestAppErrorMessage():
      RETURN ERROR NEW AppError("The message").
   END METHOD. 
 
   /**
    * Send AppError with both message and code set
    */
   @Test.
   METHOD PUBLIC VOID TestAppErrorMessageAndCode():
      RETURN ERROR NEW AppError("The message", 12345).
   END METHOD. 
 
   /**
    * Send HttpRequestError with both message and code set
    */
   @Test.
   METHOD PUBLIC VOID TestHttpRequestError():
      RETURN ERROR NEW OpenEdge.Net.HTTP.HttpRequestError(
         "theStatusCode",
         "theMethod",
         "theURI").
   END METHOD. 
 
   /**
    * Send HttpRequestError with inner error
    */
   @Test.
   METHOD PUBLIC VOID TestHttpRequestErrorInnerError():
      RETURN ERROR NEW OpenEdge.Net.HTTP.HttpRequestError(
         NEW AppError("The message", 12345),
         "theStatusCode",
         "theMethod",
         "theURI").
   END METHOD. 
 
   /**
    * Send ResizeError with all defauls
    */
   @Test.
   METHOD PUBLIC VOID TestResizeErrorAllDefaults():
      RETURN ERROR NEW OpenEdge.Core.Collections.ResizeError().
   END METHOD. 
 
   /**
    * Send ResizeError with both message and code set
    */
   @Test.
   METHOD PUBLIC VOID TestResizeErrorTwoArgs():
      RETURN ERROR NEW OpenEdge.Core.Collections.ResizeError(
         "arg1",
         "arg2").
   END METHOD. 
 
   /**
    * Send ResizeError with inner error
    */
   @Test.
   METHOD PUBLIC VOID TestResizeErrorInnerError():
      RETURN ERROR NEW OpenEdge.Core.Collections.ResizeError(
         NEW AppError("The message", 12345),
         "arg1",
         "arg2").
   END METHOD. 

   /**
    * Send SendExceptionError with all one arg
    */
   @Test.
   METHOD PUBLIC VOID TestSendExceptionErrorCode():
      RETURN ERROR NEW OpenEdge.Web.SendExceptionError(OpenEdge.Net.HTTP.StatusCodeEnum:None).
   END METHOD. 
 
   /**
    * Send SendExceptionError with code and message
    */
   @Test.
   METHOD PUBLIC VOID TestSendExceptionErrorCodeMessage():
      RETURN ERROR NEW OpenEdge.Web.SendExceptionError(OpenEdge.Net.HTTP.StatusCodeEnum:None, "status message").
   END METHOD. 
 
   /**
    * Send SendExceptionError with code and inner error
    */
   @Test.
   METHOD PUBLIC VOID TestSendExceptionErrorCodeInnerError():
      RETURN ERROR NEW OpenEdge.Web.SendExceptionError(OpenEdge.Net.HTTP.StatusCodeEnum:None,
         NEW AppError("The message", 12345)).
   END METHOD. 

   /**
    * Send StackOverflowError with all one arg
    */
   @Test.
   METHOD PUBLIC VOID TestStackOverflowErrorCode():
      RETURN ERROR NEW OpenEdge.Core.Collections.StackOverflowError().
   END METHOD. 
 
   /**
    * Send StackUnderflowError with all one arg
    */
   @Test.
   METHOD PUBLIC VOID TestStackUnderflowErrorCode():
      RETURN ERROR NEW OpenEdge.Core.Collections.StackUnderflowError().
   END METHOD. 
 
   /**
    * Send UnsupportedOperationError with two arguments
    */
   @Test.
   METHOD PUBLIC VOID TestUnsupportedOperationErrorCodeMessage():
      RETURN ERROR NEW unittests.UnsupportedError("arg1", "arg2").
   END METHOD. 
 
   /**
    * Send UnsupportedOperationError with 3 arguments
    */
   @Test.
   METHOD PUBLIC VOID TestUnsupportedOperationErrorCodeInnerError():
      RETURN ERROR NEW unittests.UnsupportedError(
         NEW AppError("The message", 12345),
         "arg1", "arg2").
   END METHOD. 

   /**
    * Send AssertionFailedError with message
    */
   @Test.
   METHOD PUBLIC VOID TestAssertionFailedErrorMessage():
      RETURN ERROR NEW OpenEdge.Core.AssertionFailedError("The quick brown fox jumps over the lazy dog").
   END METHOD. 
 
   /**
    * Send AssertionFailedError with both message, expected and actual
    */
   @Test.
   METHOD PUBLIC VOID TestAssertionFailedErrorMessageExpectedActual():
      RETURN ERROR NEW OpenEdge.Core.AssertionFailedError("The quick brown fox jumps over the lazy dog",
         "The quick brown fox jumps over the lazy dog",
         "Waltz, bad nymph, for quick jigs vex.").
   END METHOD. 
 
   /**
    * Send AssertionFailedError with message and message number
    */
   @Test.
   METHOD PUBLIC VOID TestAssertionFailedErrorMessageMessagenum():
      RETURN ERROR NEW OpenEdge.Core.AssertionFailedError("The quick brown fox jumps over the lazy dog", 12345).
   END METHOD. 

   /**
    * Send DataAdminError with one arg
    */
   @Test.
   METHOD PUBLIC VOID TestDataAdminErrorOneArg():
      RETURN ERROR NEW OpenEdge.DataAdmin.Error.DataAdminError("arg1").
   END METHOD. 
 
   /**
    * Send DataAdminError with internal error argument
    */
   @Test.
   METHOD PUBLIC VOID TestDataAdminErrorCodeInnerError():
      RETURN ERROR NEW OpenEdge.DataAdmin.Error.DataAdminError(
         "arg1",
         NEW AppError("The message", 12345)).
   END METHOD.
   
   /**
    * Send OperationError with one arg
    */
   @Test.
   METHOD PUBLIC VOID TestOperationErrorOneArg():
      RETURN ERROR NEW OpenEdge.DataAdmin.Error.OperationError("arg1").
   END METHOD. 
 
   /**
    * Send SysError with no args
    */
   @Test.
   METHOD PUBLIC VOID TestSysError():
      RETURN ERROR NEW Progress.Lang.SysError().
   END METHOD. 

   // JsonError and JsonParserError constructors are private, so they cannot be created
   // in 4gl tests

   // FIXME: SoapFaultError has a field of handle type, so it cannot be instantiated at the
   // client side while it is being de-serialized.
   
END CLASS.
