new module:ct-trading /testing /Trade Message Fixture()
Constructs a TradeMessageFixture
.
The TradeMessageFixture
serves to create a context for testing trade interactions, through the use of a
trade subscriber mock object.
Tests may use the TradeMessageFixture
to:
- trigger mock server events:
given(PM is in state A)
when("trade.eventReceived => 'ExecuteAck|TRADE_CONF_EXECUTE_DATA'")
then(PM is in state B)
- trigger mock server's trading status changes:
given(PM is in state A)
when("trade.statusEnabled => false")
then(PM is in state B)
- verify that a trade object has sent the expected event:
given(PM is in state A)
when (execute button is pressed)
then ("trade.eventSent = 'Execute|TRADE_EXECUTE_DATA'")
- Implements:
Methods
add Named Value Map(name, values)
This method enables a FixtureFactory to register a set of record identifiers and corresponding map of mock record
field data with this TradeMessageFixture. Tests using the fixture to receive mock messages or verify events sent by
the trade are able to refer to record data using property value '
Parameters:
Name | Type | Description |
---|---|---|
name |
String | the record identifier. |
values |
Map | the record data map from field data to field value. |
can Handle Property()
TradeMessageFixture handles properties 'eventReceived', 'eventSent' and 'statusEnabled'.
do Given(property Name, value)
This method can be used with the 'eventReceived' or 'statusEnabled' properties to trigger the stub to simulate these events being received from the server. The 'eventReceived' property must be supplied with a trade event name and optional data map id, in the format NAME|DATA, where DATA is the key for one of the name-value pairs already supplied (TradeMessageFixture.addNamedValueMap).
Parameters:
Name | Type | Description |
---|---|---|
propertyName |
String | The property name. |
value |
Variant | The value to check. |
- Implements:
- See:
do Then(property Name, value)
This method can be used to check whether the last trade event 'sent' by the trading stub was the one expected. This method must be used with the property name 'eventSent', while the value is the event name and data expected in the format NAME|DATA.
Parameters:
Name | Type | Description |
---|---|---|
propertyName |
String | The property name. |
value |
Variant | The value to set. |
- Implements:
- See:
do When(property Name, value)
This method can be used with the 'eventReceived' or 'statusEnabled' properties to trigger the stub to simulate these events being received from the server.
Parameters:
Name | Type | Description |
---|---|---|
propertyName |
String | The property name. |
value |
Variant | The value to set. |
- Implements:
- See:
set Trade Message Service Stub(trade Message Service Stub)
Sets a TradeMessageServiceStub to be used by this fixture to simulate trade events.
Parameters:
Name | Type | Description |
---|---|---|
tradeMessageServiceStub |
module:ct-trading |
the trade subscriber stub. |
tear Down()
This method is called just after a GWT test. This optional interface method can be implemented if the fixture is required to correctly tear down the system-under-test after each test or to reset any state held in the fixture's implementation.
- Implements: