Forum Post: RE: ABL UNIT use of OpenEdge.Core.Asset:IsType()

  • Thread starter Thread starter Peter Judge
  • Start date Start date
Status
Not open for further replies.
P

Peter Judge

Guest
The Assert class contains a bunch of general assertions, some of which are used in places other than the ABLUnit framework, and for other reasons that unit tests. The main other reason is to validation input parameter values. There are a number of procedure libraries (PL files) in the $DLC/src directory and its children, which contain source that may use various assertions for validation checks. Check out the constructors in the DecisionService class in the OpenEdge.BusinessRules.pl for a quick example. This other use is why these aren't doc'ed. The IsType and their NotType work either on object references or handles. The former case is possibly simpler to deal with in code via the TYPE-OF() statement or the IsA() method on Progress.Lang.Class, but use the Assert class because it encapsulates the code and the errors thrown if the assertion fails. The handle types does the same but for handles - this is a little less 'strong' if you will, because of the weak-type nature of handle. The signatures and comments of the various IsType and NotType methods are /** Asserts that a handle is valid and of a particular datatype @param phArgument The handle being checked. @param poCheckType The type the handle/variable being checked should be. @param pcName The name of the variable/handle. @throws AssertionFailedError Error thrown if the handle is not valid or not of a particular datatype.*/ method public static void IsType(input phArgument as handle, input poCheckType as DataTypeEnum, input pcName as character): /** Asserts that a handle is valid and of a particular datatype @param phArgument The handle being checked. @param poCheckType The type the handle/variable being checked should be. @throws AssertionFailedError Error thrown if the handle is not valid or not of a particular datatype*/ method public static void IsType(input phArgument as handle, input poCheckType as DataTypeEnum): /** Asserts that a object is valid and of a particular type @param poArgument The Object being checked. @param poType The type the being checked. @throws AssertionFailedError Error thrown if the object is not valid and not of particular type.*/ method public static void IsType(input poArgument as Object, poType as Progress.Lang.Class): /** Asserts that a object extent is valid and of a particular type for each array item @param poArgument The Object being checked. @param poType The type the being checked. @throws AssertionFailedError Error thrown if the object array is not valid any of the array item is not of particular type.*/ method public static void IsType(input poArgument as Object extent, poType as Progress.Lang.Class): /** Asserts that a object is valid and not of a particular type @param poArgument The Object being checked. @param poType The type the being checked. @throws AssertionFailedError Error thrown if the object is not valid and of particular type.*/ method public static void NotType(input poArgument as Object, poType as Progress.Lang.Class): /** Asserts that a handle is valid and not of a particular datatype @param phArgument The handle being checked. @param poCheckType The type the handle/variable being checked should be. @param pcName the identifying name for the AssertionFailedError. @throws AssertionFailedError Error thrown if the handle is not valid or of a particular datatype*/ method public static void NotType(input phArgument as handle, input poCheckType as DataTypeEnum, input pcName as character): /** Asserts that a handle is valid and not of a particular datatype @param phArgument The handle being checked. @param poCheckType The type the handle/variable being checked should be. @throws AssertionFailedError Error thrown if the handle is not valid or of a particular datatype*/ method public static void NotType(input phArgument as handle, input poCheckType as DataTypeEnum): hth

Continue reading...
 
Status
Not open for further replies.
Back
Top