new module:ct-trading /testing /Trade Message Service Stub()
Constructs an instance of TradeMessageServiceStub
.
A TradeSubscribeStub stubs out a module:ct-trading/trademodel/TradeMessageService
instance
for the purpose of testing trades and trading components in acceptance tests and workbenches. The
TradeMessageServiceStub mocks out a subscription for only one trade, as only one is typically required
in a test or in a component's workbench.
- Implements:
Methods
add Event Logger(fLogger)
This method registers an event logging function with this mock TradeMessageService. This function is called for all events Events being "sent" by a trade and "received" from a server mock. A component workbench or a mock server will typically register a logger in order to display or be informed of the mocked trade events. Callback functions must handle the following 3 parameters:
- the event name (String)
- the direction of the event (eg. send/ receive) (String)
- the event data (Map)
Parameters:
Name | Type | Description |
---|---|---|
fLogger |
function | the callback function to log mock trade events |
add Trade(oTrade)
Assigns the trade as the subscriber to mocked trade messages.
Parameters:
Name | Type | Description |
---|---|---|
oTrade |
module:ct-trading |
the trade object. |
receive Server Trade Event(sEvent Name, mData)
This method is called by a mock trade server to simulate the receipt of a trade event from Liberator via SL4B. The event is propagated to the Trade subscribed via this mock trade subscriber. This stub will print out the message to a logger if one has been defined.
Parameters:
Name | Type | Description |
---|---|---|
sEventName |
String | the event name that is being received from the server |
mData |
Map | Object | the data being received for this event |
receive Trade Channel Status Change(bEnabled)
This method is called by a mock trade server to simulate a channel status change of the trade subscriber. The change event is propagated to the Trade subscribed via this mock trade subscriber. The new subscriber status will be printed to a logger if one has been defined.
Parameters:
Name | Type | Description |
---|---|---|
bEnabled |
boolean | the new trading status received |
remove Trade(oTrade)
Unregisters the trade subscribed to mocked trade messages.
Parameters:
Name | Type | Description |
---|---|---|
oTrade |
module:ct-trading |
the trade object. |
send Trade Event(sEvent Name, oTrade, oData)
This method is called by a module:ct-trading/trademodel/Trade
to simulate the sending of
a trade event to Liberator via SL4B. This stub will print out the message to a logger if one has been
defined.
Parameters:
Name | Type | Description |
---|---|---|
sEventName |
String | the event name that is being sent to the server. |
oTrade |
module:ct-trading |
the trade object. |
oData |
module:ct-trading |
the data being sent with this event. |