public async void ShouldReceiveExecutedTradeInBlotter()
{
var pass = false;
var testCcyPair = "XXXXXB";
_blotterServiceInstance = await _heartbeatStream
.Where(hb => hb.Type == ServiceTypes.Blotter)
.Select(hb => hb.Instance)
.Take(1);
// this is the callback when the blotter receives the executed trade notification
Action<dynamic> blotterCallbackAssertion = d =>
{
foreach (var dto in d)
{
foreach (var trade in dto.Trades)
{
if (trade.CurrencyPair == testCcyPair && trade.Status == "Done")
{
Console.WriteLine(dto);
// set the assertion
pass = true;
_timeoutCancellationTokenSource.Cancel(false);
return;
}
}
}
};
await _channel.RealmProxy.TopicContainer
.GetTopicByUri(BlotterUpdatesReplyTo)
.Subscribe(new WampSubscriber(blotterCallbackAssertion), new SubscribeOptions());
// subscribe to blotter with the callback
_channel.RealmProxy.RpcCatalog.Invoke(
new RpcCallback(() => { }),
new CallOptions(),
$"{_blotterServiceInstance}.getTradesStream",
new object[] {new {ReplyTo = BlotterUpdatesReplyTo, Payload = new NothingDto()}});
// call execute trade
await CallExecuteTrade(testCcyPair);
Assert.True(pass);
}