testbox.system

Class Assertion

railo-context.Component
        extended by testbox.system.Assertion
Class Attributes:
  • synchronized : false
  •  
  • accessors : false
  •  
  • persistent : false
  •  

    Copyright Since 2005 TestBox Framework by Luis Majano and Ortus Solutions, Corp www.coldbox.org | www.ortussolutions.com This object represents our Assertion style DSL for Unit style testing

    Method Summary
    any assert(boolean expression, [any message=''])
         Assert that the passed expression is true.
    any between(any actual, any min, any max, [any message=''])
         Assert that the passed in actual number or date is between the passed in min and max values.
    any closeTo(any expected, any actual, any delta, [any datePart=''], [any message=''])
         Assert that the passed in actual number or date is expected to be close to it within +/- a passed delta and optional datepart.
    any deepKey(struct target, string key, [any message=''])
         Assert that a given key exists in the passed in struct by searching the entire nested structure.
    private any equalize(any expected, any actual)
         PRIVATE Methods **********************************.
    any fail([any message=''])
         Fail assertion.
    private any getIdentityHashCode(any target)
    any getStringName(any obj)
         Get a string name representation of an incoming object.
    private any getTargetLength(any target)
    any includes(any target, any needle, [any message=''])
         Assert that the given "needle" argument exists in the incoming string or array with no case-sensitivity.
    any includesWithCase(any target, any needle, [any message=''])
         Assert that the given "needle" argument exists in the incoming string or array with case-sensitivity.
    any instanceOf(any actual, string typeName, [any message=''])
         Assert that the actual object is of the expected instance type.
    any isEmpty(any target, [any message=''])
         Assert that a a given string, array, structure or query is empty.
    any isEqual(any expected, any actual, [any message=''])
         Assert something is equal to each other, no case is required.
    any isEqualWithCase(string expected, string actual, [any message=''])
         Assert strings are equal to each other with case.
    any isFalse(boolean actual, [any message=''])
         Assert something is false.
    any isGT(any actual, any target, [any message=''])
         Assert that the actual value is greater than the target value.
    any isGTE(any actual, any target, [any message=''])
         Assert that the actual value is greater than or equal the target value.
    any isLT(any actual, any target, [any message=''])
         Assert that the actual value is less than the target value.
    any isLTE(any actual, any target, [any message=''])
         Assert that the actual value is less than or equal the target value.
    any isNotEmpty(any target, [any message=''])
         Assert that a a given string, array, structure or query is not empty.
    any isNotEqual(any expected, any actual, [any message=''])
         Assert something is not equal to each other, no case is required.
    any isNotSameInstance(any expected, any actual, [any message=''])
         Assert an object is not the same instance as another object.
    any isSameInstance(any expected, any actual, [any message=''])
         Assert an object is the same instance as another object.
    any isTrue(boolean actual, [any message=''])
         Assert something is true.
    any key(any target, string key, [any message=''])
         Assert that a given key exists in the passed in struct/object.
    any lengthOf(any target, string length, [any message=''])
         Assert the size of a given string, array, structure or query.
    any match(string actual, string regex, [any message=''])
         Assert that the actual data matches the incoming regular expression with no case sensitivity.
    any matchWithCase(string actual, string regex, [any message=''])
         Assert that the actual data matches the incoming regular expression with case sensitivity.
    any notDeepKey(struct target, string key, [any message=''])
         Assert that a given key DOES NOT exists in the passed in struct by searching the entire nested structure.
    any notIncludes(any target, any needle, [any message=''])
         Assert that the given "needle" argument exists in the incoming string or array with no case-sensitivity.
    any notIncludesWithCase(any target, any needle, [any message=''])
         Assert that the given "needle" argument does not exist in the incoming string or array with case-sensitivity.
    any notInstanceOf(any actual, string typeName, [any message=''])
         Assert that the actual object is NOT of the expected instance type.
    any notKey(any target, string key, [any message=''])
         Assert that a given key DOES NOT exist in the passed in struct/object.
    any notLengthOf(any target, string length, [any message=''])
         Assert the size of a given string, array, structure or query.
    any notMatch(string actual, string regex, [any message=''])
         Assert that the actual data does NOT match the incoming regular expression with no case sensitivity.
    any notNull([any actual], [any message=''])
         Assert something is not null.
    any notThrows(any target, [any type=''], [any regex=''], [any message=''])
         Assert that the passed in function will NOT throw an exception, an exception of a specified type or exception message regex.
    any notTypeOf(string type, any actual, [any message=''])
         Assert that is NOT a type of the incoming actual data, it uses the internal ColdFusion isValid() function behind the scenes.
    any null([any actual], [any message=''])
         Assert something is null.
    any throws(any target, [any type=''], [any regex='.*'], [any message=''])
         Assert that the passed in function will throw an exception.
    any typeOf(string type, any actual, [any message=''])
         Assert the type of the incoming actual data, it uses the internal ColdFusion isValid() function behind the scenes.
     
    Methods inherited from class railo-context.Component
    None

    Method Detail

    assert

    public any assert(boolean expression, [any message=''])

    Assert that the passed expression is true

    Parameters:
    expression - The expression to test
    message - The message to send in the failure

    between

    public any between(any actual, any min, any max, [any message=''])

    Assert that the passed in actual number or date is between the passed in min and max values

    Parameters:
    actual - The actual number or date to evaluate
    min - The expected min number or date
    max - The expected max number or date
    message - The message to send in the failure

    closeTo

    public any closeTo(any expected, any actual, any delta, [any datePart=''], [any message=''])

    Assert that the passed in actual number or date is expected to be close to it within +/- a passed delta and optional datepart

    Parameters:
    expected - The expected number or date
    actual - The actual number or date
    delta - The +/- delta to range it
    datePart - If passed in values are dates, then you can use the datepart to evaluate it
    message - The message to send in the failure

    deepKey

    public any deepKey(struct target, string key, [any message=''])

    Assert that a given key exists in the passed in struct by searching the entire nested structure

    Parameters:
    target - The target object/struct
    key - The key to check for existence anywhere in the nested structure
    message - The message to send in the failure

    equalize

    private any equalize(any expected, any actual)

    PRIVATE Methods **********************************

    Parameters:
    expected
    actual

    fail

    public any fail([any message=''])

    Fail assertion

    Parameters:
    message - The message to send in the failure

    getIdentityHashCode

    private any getIdentityHashCode(any target)

    Parameters:
    target

    getStringName

    public any getStringName(any obj)

    Get a string name representation of an incoming object.

    Parameters:
    obj

    getTargetLength

    private any getTargetLength(any target)

    Parameters:
    target

    includes

    public any includes(any target, any needle, [any message=''])

    Assert that the given "needle" argument exists in the incoming string or array with no case-sensitivity

    Parameters:
    target - The target object to check if the incoming needle exists in. This can be a string or array
    needle - The substring to find in a string or the value to find in an array
    message - The message to send in the failure

    includesWithCase

    public any includesWithCase(any target, any needle, [any message=''])

    Assert that the given "needle" argument exists in the incoming string or array with case-sensitivity

    Parameters:
    target - The target object to check if the incoming needle exists in. This can be a string or array
    needle - The substring to find in a string or the value to find in an array
    message - The message to send in the failure

    instanceOf

    public any instanceOf(any actual, string typeName, [any message=''])

    Assert that the actual object is of the expected instance type

    Parameters:
    actual - The actual data to check
    typeName - The typename to check
    message - The message to send in the failure

    isEmpty

    public any isEmpty(any target, [any message=''])

    Assert that a a given string, array, structure or query is empty

    Parameters:
    target - The target object to check the length for, this can be a string, array, structure or query
    message - The message to send in the failure

    isEqual

    public any isEqual(any expected, any actual, [any message=''])

    Assert something is equal to each other, no case is required

    Parameters:
    expected - The expected data
    actual - The actual data to test
    message - The message to send in the failure

    isEqualWithCase

    public any isEqualWithCase(string expected, string actual, [any message=''])

    Assert strings are equal to each other with case.

    Parameters:
    expected - The expected data
    actual - The actual data to test
    message - The message to send in the failure

    isFalse

    public any isFalse(boolean actual, [any message=''])

    Assert something is false

    Parameters:
    actual - The actual data to test
    message - The message to send in the failure

    isGT

    public any isGT(any actual, any target, [any message=''])

    Assert that the actual value is greater than the target value

    Parameters:
    actual - The actual value
    target - The target value
    message - The message to send in the failure

    isGTE

    public any isGTE(any actual, any target, [any message=''])

    Assert that the actual value is greater than or equal the target value

    Parameters:
    actual - The actual value
    target - The target value
    message - The message to send in the failure

    isLT

    public any isLT(any actual, any target, [any message=''])

    Assert that the actual value is less than the target value

    Parameters:
    actual - The actual value
    target - The target value
    message - The message to send in the failure

    isLTE

    public any isLTE(any actual, any target, [any message=''])

    Assert that the actual value is less than or equal the target value

    Parameters:
    actual - The actual value
    target - The target value
    message - The message to send in the failure

    isNotEmpty

    public any isNotEmpty(any target, [any message=''])

    Assert that a a given string, array, structure or query is not empty

    Parameters:
    target - The target object to check the length for, this can be a string, array, structure or query
    message - The message to send in the failure

    isNotEqual

    public any isNotEqual(any expected, any actual, [any message=''])

    Assert something is not equal to each other, no case is required

    Parameters:
    expected - The expected data
    actual - The actual data to test
    message - The message to send in the failure

    isNotSameInstance

    public any isNotSameInstance(any expected, any actual, [any message=''])

    Assert an object is not the same instance as another object

    Parameters:
    expected - The expected data
    actual - The actual data to test
    message - The message to send in the failure

    isSameInstance

    public any isSameInstance(any expected, any actual, [any message=''])

    Assert an object is the same instance as another object

    Parameters:
    expected - The expected data
    actual - The actual data to test
    message - The message to send in the failure

    isTrue

    public any isTrue(boolean actual, [any message=''])

    Assert something is true

    Parameters:
    actual - The actual data to test
    message - The message to send in the failure

    key

    public any key(any target, string key, [any message=''])

    Assert that a given key exists in the passed in struct/object

    Parameters:
    target - The target object/struct
    key - The key to check for existence
    message - The message to send in the failure

    lengthOf

    public any lengthOf(any target, string length, [any message=''])

    Assert the size of a given string, array, structure or query

    Parameters:
    target - The target object to check the length for, this can be a string, array, structure or query
    length - The length to check
    message - The message to send in the failure

    match

    public any match(string actual, string regex, [any message=''])

    Assert that the actual data matches the incoming regular expression with no case sensitivity

    Parameters:
    actual - The actual data to check
    regex - The regex to check with
    message - The message to send in the failure

    matchWithCase

    public any matchWithCase(string actual, string regex, [any message=''])

    Assert that the actual data matches the incoming regular expression with case sensitivity

    Parameters:
    actual - The actual data to check
    regex - The regex to check with
    message - The message to send in the failure

    notDeepKey

    public any notDeepKey(struct target, string key, [any message=''])

    Assert that a given key DOES NOT exists in the passed in struct by searching the entire nested structure

    Parameters:
    target - The target object/struct
    key - The key to check for existence anywhere in the nested structure
    message - The message to send in the failure

    notIncludes

    public any notIncludes(any target, any needle, [any message=''])

    Assert that the given "needle" argument exists in the incoming string or array with no case-sensitivity

    Parameters:
    target - The target object to check if the incoming needle exists in. This can be a string or array
    needle - The substring to find in a string or the value to find in an array
    message - The message to send in the failure

    notIncludesWithCase

    public any notIncludesWithCase(any target, any needle, [any message=''])

    Assert that the given "needle" argument does not exist in the incoming string or array with case-sensitivity

    Parameters:
    target - The target object to check if the incoming needle exists in. This can be a string or array
    needle - The substring to find in a string or the value to find in an array
    message - The message to send in the failure

    notInstanceOf

    public any notInstanceOf(any actual, string typeName, [any message=''])

    Assert that the actual object is NOT of the expected instance type

    Parameters:
    actual - The actual data to check
    typeName - The typename to check
    message - The message to send in the failure

    notKey

    public any notKey(any target, string key, [any message=''])

    Assert that a given key DOES NOT exist in the passed in struct/object

    Parameters:
    target - The target object/struct
    key - The key to check for existence
    message - The message to send in the failure

    notLengthOf

    public any notLengthOf(any target, string length, [any message=''])

    Assert the size of a given string, array, structure or query

    Parameters:
    target - The target object to check the length for, this can be a string, array, structure or query
    length - The length to check
    message - The message to send in the failure

    notMatch

    public any notMatch(string actual, string regex, [any message=''])

    Assert that the actual data does NOT match the incoming regular expression with no case sensitivity

    Parameters:
    actual - The actual data to check
    regex - The regex to check with
    message - The message to send in the failure

    notNull

    public any notNull([any actual], [any message=''])

    Assert something is not null

    Parameters:
    actual - The actual data to test
    message - The message to send in the failure

    notThrows

    public any notThrows(any target, [any type=''], [any regex=''], [any message=''])

    Assert that the passed in function will NOT throw an exception, an exception of a specified type or exception message regex

    Parameters:
    target - The target function to execute and check for exceptions
    type - Match this type with the exception thrown
    regex - Match this regex against the message+detail of the exception
    message - The message to send in the failure

    notTypeOf

    public any notTypeOf(string type, any actual, [any message=''])

    Assert that is NOT a type of the incoming actual data, it uses the internal ColdFusion isValid() function behind the scenes

    Parameters:
    type - The type to check, valid types are: array, binary, boolean, component, date, time, float, numeric, integer, query, string, struct, url, uuid
    actual - The actual data to check
    message - The message to send in the failure

    null

    public any null([any actual], [any message=''])

    Assert something is null

    Parameters:
    actual - The actual data to test
    message - The message to send in the failure

    throws

    public any throws(any target, [any type=''], [any regex='.*'], [any message=''])

    Assert that the passed in function will throw an exception

    Parameters:
    target - The target function to execute and check for exceptions
    type - Match this type with the exception thrown
    regex - Match this regex against the message + detail of the exception
    message - The message to send in the failure

    typeOf

    public any typeOf(string type, any actual, [any message=''])

    Assert the type of the incoming actual data, it uses the internal ColdFusion isValid() function behind the scenes

    Parameters:
    type - The type to check, valid types are: array, binary, boolean, component, date, time, float, numeric, integer, query, string, struct, url, uuid
    actual - The actual data to check
    message - The message to send in the failure