Caplin Trader 5.1.0

Class: module:ct-trading/testing/TOBOFixture

module:ct-trading/testing/TOBOFixture()

new module:ct-trading/testing/TOBOFixture()

Constructs a TOBOFixture.

The TOBOFixture serves to provide a way for tests to interact with the TOBOUserService by setting the ability for the test to act as a user who can trade on behalf of other users, setting the list of TOBO users and accounts that the test can user to trade on behalf of, and setting and querying the selected TOBO user and account to trade with.

Use of the Fixture assumes that a module:ct-trading/testing/TOBOUserServiceStub is registered as a service on the module:ct-core/ServiceRegistry with the alias 'caplin.tobo-user-service'.

Tests may use the TOBOFixture to:

  • set the user type and (un)set the ability of the test to trade on behalf of TOBO users: given('tobo.UserType = 'SUPER_USER'')
    and('tobo.userCanTradeOnBehalfOf = true')
    ...
  • set the TOBO user and account lists: given('tobo.TOBOUserList = '['user1','user2']'')
    and('tobo.TOBOAccountList = '['acct1','acct2']'')
    ...
  • set the TOBO user and account to use for trading: given('tobo.TOBOUser = 'user1'')
    and('tobo.TOBOAccount = 'acct5'')
    ...
  • verify the TOBO user and account: ...
    then('tobo.TOBOUser = 'user1'')
    and('tobo.TOBOAccount = 'acct5'')
Implements:

Methods

canHandleProperty(sProperty)

TradeMessageFixture handles properties 'UserType', 'userCanTradeOnBehalfOf', 'TOBOUser', 'TOBOUserList', 'TOBOAccount' and 'TOBOAccountList'.

Parameters:
Name Type Description
sProperty String

The property to check.

Implements:
See:

doGiven(sPropertyName, vValue)

This method is used to set the state of the TOBOUserService, determining whether the test can trade on behalf of a TOBO user, the test's user type, the TOBO user and account lists available to the test and the TOBO user and account to be used by the test for trading.

Parameters:
Name Type Description
sPropertyName String

The property name

vValue Variant

the value to check

Implements:
See:

doThen(sPropertyName, vValue)

This method can be used by a test to verify whether the user type and TOBO user and account on the TOBOUserService have the expected values.

Parameters:
Name Type Description
sPropertyName String

The property name

vValue Variant

the value to set

Implements:
See:

doWhen(propertyName, value)

This method is called in order to manipulate a property on the system under test in a when clause.

Parameters:
Name Type Description
propertyName String

The property to be changed.

value String

The new value of the property.

Implements: